🐛 Fix: url encode bug && copy-paste url encode bug

ISSUES CLOSED: #996
This commit is contained in:
PiEgg
2022-10-24 17:14:39 +08:00
parent 404d7667e0
commit 4de7a1d5f2
4 changed files with 9 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ export const isUrl = (url: string): boolean => (url.startsWith('http://') || url
export const isUrlEncode = (url: string): boolean => {
url = url || ''
try {
return url !== decodeURIComponent(url)
return url !== decodeURI(url)
} catch (e) {
// if some error caught, try to let it go
return true
@@ -11,7 +11,7 @@ export const isUrlEncode = (url: string): boolean => {
export const handleUrlEncode = (url: string): string => {
if (!isUrlEncode(url)) {
url = encodeURIComponent(url)
url = encodeURI(url)
}
return url
}