{“ast”:null,“code”:“/**n * When source maps are enabled, `style-loader` uses a link element with a data-uri ton * embed the css on the page. This breaks all relative urls because now they are relative to an * bundle instead of the current page.n *n * One solution is to only use full urls, but that may be impossible.n *n * Instead, this function "fixes" the relative urls to be absolute according to the current page location.n *n * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.n *n */nmodule.exports = function (css) {n // get current locationn var location = typeof window !== "undefined" && window.location;nn if (!location) {n throw new Error("fixUrls requires window.location");n } // blank or null?nnn if (!css || typeof css !== "string") {n return css;n }nn var baseUrl = location.protocol + "//" + location.host;n var currentDir = baseUrl + location.pathname.replace(/\/*$/, "/"); // convert each url(…)nn /*n This regular expression is just a way to recursively match brackets withinn a string.n t /url\s*\( = Match on the word "url" with any whitespace after it and then a parensn ( = Start a capturing groupn (?: = Start a non-capturing groupn [^)(] = Match anything that isn't a parenthesesn | = ORn \( = Match a start parenthesesn (?: = Start another non-capturing groupsn [^)(]+ = Match anything that isn't a parenthesesn | = ORn \( = Match a start parenthesesn [^)(]* = Match anything that isn't a parenthesesn \) = Match a end parenthesesn ) = End Groupn *\) = Match anything and then a close parensn ) = Close non-capturing groupn * = Match anythingn ) = Close capturing groupn \) = Match a close parensn t /gi = Get all matches, not the first. Be case insensitive.n */nn var fixedCss = css.replace(/url\s*\(((?:|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function (fullMatch, origUrl) {n // strip quotes (if they exist)n var unquotedOrigUrl = origUrl.trim().replace(/^"(.*)"$/, function (o, $1) {n return $1;n }).replace(/^'(.*)'$/, function (o, $1) {n return $1;n }); // already a full url? no changenn if (/^(#|data:|\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {n return fullMatch;n } // convert the url to a full urlnnn var newUrl;nn if (unquotedOrigUrl.indexOf("//") === 0) {n //TODO: should we add protocol?n newUrl = unquotedOrigUrl;n } else if (unquotedOrigUrl.indexOf("/") === 0) {n // path should be relative to the base urln newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'n } else {n // path should be relative to current directoryn newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'n } // send back the fixed url(…)nnn return "url(" + JSON.stringify(newUrl) + ")";n }); // send back the fixed cssnn return fixedCss;n};”,“map”:null,“metadata”:{},“sourceType”:“module”}