UriToHash 哈希取值

8 min read
function UriToHash(uri = '') {
    if (!uri) return '';
    // 通过'/'分割URI,取最后一部分
    const lastSegment = uri.split('/').pop();
    // 如果存在lastSegment,再通过'_'分割并取第一部分
    if (lastSegment) {
        return lastSegment.split('_')[0];
    }
    return '';
}

使用提供的URL进行测试后,该UriToHash函数返回的哈希值为9efe6192-4cb6-4560-ba12-5cdaac7ec0cc。这个结果来自于URL中最后一个/后的部分,然后再通过_分割并取第一部分得到的