1 | "use strict";
|
2 |
|
3 | module.exports = function (url, options) {
|
4 | if (!options) {
|
5 | options = {};
|
6 | }
|
7 |
|
8 | if (!url) {
|
9 | return url;
|
10 | }
|
11 |
|
12 | url = String(url.__esModule ? url.default : url);
|
13 |
|
14 | if (/^['"].*['"]$/.test(url)) {
|
15 | url = url.slice(1, -1);
|
16 | }
|
17 |
|
18 | if (options.hash) {
|
19 | url += options.hash;
|
20 | }
|
21 |
|
22 |
|
23 |
|
24 | if (/["'() \t\n]|(%20)/.test(url) || options.needQuotes) {
|
25 | return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), "\"");
|
26 | }
|
27 |
|
28 | return url;
|
29 | }; |
\ | No newline at end of file |