Skip to content
Snippets Groups Projects
Unverified Commit a3cdb4cc authored by tamaina's avatar tamaina Committed by GitHub
Browse files

fix: Handle decodeURIComponent error (#8411)

parent e6f455a9
No related branches found
No related tags found
No related merge requests found
...@@ -49,14 +49,22 @@ export default defineComponent({ ...@@ -49,14 +49,22 @@ export default defineComponent({
}, {}, 'closed'); }, {}, 'closed');
}); });
function safeURIDecode(str: string) {
try {
return decodeURIComponent(str);
} catch {
return str;
}
}
return { return {
local, local,
schema: url.protocol, schema: url.protocol,
hostname: decodePunycode(url.hostname), hostname: decodePunycode(url.hostname),
port: url.port, port: url.port,
pathname: decodeURIComponent(url.pathname), pathname: safeURIDecode(url.pathname),
query: decodeURIComponent(url.search), query: safeURIDecode(url.search),
hash: decodeURIComponent(url.hash), hash: safeURIDecode(url.hash),
self: self, self: self,
attr: self ? 'to' : 'href', attr: self ? 'to' : 'href',
target: self ? null : '_blank', target: self ? null : '_blank',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment