原来需要对URL中的符号进行编码
I made S3Encode,相同的 npm 存储库
这是一个完成这项工作的函数
function encode(filename) {
const encodings = {
'\+': "%2B",
'\!': "%21",
'\"': "%22",
'\#': "%23",
'\$': "%24",
'\&': "%26",
'\'': "%27",
'\(': "%28",
'\)': "%29",
'\*': "%2A",
'\,': "%2C",
'\:': "%3A",
'\;': "%3B",
'\=': "%3D",
'\?': "%3F",
'\@': "%40",
};
return filename.replace(
/([+!"#$&'()*+,:;=?@])/img,
match => encodings[match]
);
}
使用此功能anchor
标签及相关
eg
<a href=encode("/AniketFuryRocks/What is Lorem Ipsum?")></a>