Skip to content

Commit 4c70e9b

Browse files
committed
🐛 Fix: url encode bug
1 parent 1720c5f commit 4c70e9b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/common.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ export const isUrl = (url: string): boolean => (url.startsWith('http://') || url
1414
export const isUrlEncode = (url: string): boolean => {
1515
url = url || ''
1616
try {
17-
return url !== decodeURIComponent(url)
17+
// the whole url encode or decode shold not use encodeURIComponent or decodeURIComponent
18+
return url !== decodeURI(url)
1819
} catch (e) {
1920
// if some error caught, try to let it go
2021
return true
2122
}
2223
}
2324
export const handleUrlEncode = (url: string): string => {
2425
if (!isUrlEncode(url)) {
25-
url = encodeURIComponent(url)
26+
url = encodeURI(url)
2627
}
2728
return url
2829
}

0 commit comments

Comments
 (0)