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.

21 lines
413 B

2 years ago
'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;