🐛 Fix: paste url encoding bug

ISSUES CLOSED: #454
This commit is contained in:
Molunerfinn
2020-06-28 15:30:58 +08:00
parent a693544291
commit 59d3eba86d
3 changed files with 20 additions and 3 deletions

View File

@@ -1 +1,17 @@
export const isUrl = (url: string): boolean => (url.startsWith('http://') || url.startsWith('https://'))
export const isUrlEncode = (url: string): boolean => {
url = url || ''
try {
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 = encodeURI(url)
}
return url
}