Skip to content

Commit

Permalink
🐛 Fix: return true if decodeURI throw error to avoid crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Molunerfinn committed Apr 4, 2020
1 parent 7a6b39c commit d09d77a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export const isUrl = (url: string): boolean => (url.startsWith('http://') || url.startsWith('https://'))
export const isUrlEncode = (url: string): boolean => {
url = url || ''
return url !== decodeURI(url)
try {
return url !== decodeURI(url)
} catch (e) {
// if some error catched, try to let it go
return true
}
}
export const handleUrlEncode = (url: string): string => {
if (!isUrlEncode(url)) {
Expand Down

0 comments on commit d09d77a

Please sign in to comment.