UNPKG

610 BJavaScriptView Raw
1"use strict";
2const url_1 = require("url");
3const querystring_1 = require("querystring");
4const encodeURL = (str) => {
5 if ((0, url_1.parse)(str).protocol) {
6 const parsed = new URL(str);
7 // Exit if input is a data url
8 if (parsed.origin === 'null')
9 return str;
10 parsed.search = encodeURI((0, querystring_1.unescape)(parsed.search));
11 // preserve IDN
12 return (0, url_1.format)(parsed, { unicode: true });
13 }
14 return encodeURI((0, querystring_1.unescape)(str));
15};
16module.exports = encodeURL;
17//# sourceMappingURL=encode_url.js.map
\No newline at end of file