You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
413 B
20 lines
413 B
'use strict'; |
|
|
|
const { parse, format } = require('url'); |
|
const { unescape } = require('querystring'); |
|
|
|
const decodeURL = str => { |
|
if (parse(str).protocol) { |
|
const parsed = new URL(str); |
|
|
|
// Exit if input is a data url |
|
if (parsed.origin === 'null') return str; |
|
|
|
const url = format(parsed, { unicode: true }); |
|
return unescape(url); |
|
} |
|
|
|
return unescape(str); |
|
}; |
|
|
|
module.exports = decodeURL;
|
|
|