|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
597 bytes
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | module.exports = function (url, options) {
|
|---|
| 4 | if (!options) {
|
|---|
| 5 | options = {};
|
|---|
| 6 | }
|
|---|
| 7 | if (!url) {
|
|---|
| 8 | return url;
|
|---|
| 9 | }
|
|---|
| 10 | url = String(url.__esModule ? url.default : url);
|
|---|
| 11 |
|
|---|
| 12 | // If url is already wrapped in quotes, remove them
|
|---|
| 13 | if (/^['"].*['"]$/.test(url)) {
|
|---|
| 14 | url = url.slice(1, -1);
|
|---|
| 15 | }
|
|---|
| 16 | if (options.hash) {
|
|---|
| 17 | url += options.hash;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | // Should url be wrapped?
|
|---|
| 21 | // See https://drafts.csswg.org/css-values-3/#urls
|
|---|
| 22 | if (/["'() \t\n]|(%20)/.test(url) || options.needQuotes) {
|
|---|
| 23 | return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), "\"");
|
|---|
| 24 | }
|
|---|
| 25 | return url;
|
|---|
| 26 | }; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.