Skip to content

Commit

Permalink
🐛 Fix: url encode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Molunerfinn committed Oct 24, 2022
1 parent 1720c5f commit 4c70e9b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ export const isUrl = (url: string): boolean => (url.startsWith('http://') || url
export const isUrlEncode = (url: string): boolean => {
url = url || ''
try {
return url !== decodeURIComponent(url)
// the whole url encode or decode shold not use encodeURIComponent or decodeURIComponent
return url !== decodeURI(url)
} catch (e) {
// if some error caught, try to let it go
return true
}
}
export const handleUrlEncode = (url: string): string => {
if (!isUrlEncode(url)) {
url = encodeURIComponent(url)
url = encodeURI(url)
}
return url
}
Expand Down

0 comments on commit 4c70e9b

Please sign in to comment.