{"ast":null,"code":"/**\n * When source maps are enabled, `style-loader` uses a link element with a data-uri to\n * embed the css on the page. This breaks all relative urls because now they are relative to a\n * 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 location\n  var location = typeof window !== \"undefined\" && window.location;\n\n  if (!location) {\n    throw new Error(\"fixUrls requires window.location\");\n  } // blank or null?\n\n\n  if (!css || typeof css !== \"string\") {\n    return css;\n  }\n\n  var baseUrl = location.protocol + \"//\" + location.host;\n  var currentDir = baseUrl + location.pathname.replace(/\\/[^\\/]*$/, \"/\"); // convert each url(...)\n\n  /*\n  This regular expression is just a way to recursively match brackets within\n  a string.\n  \t /url\\s*\\(  = Match on the word \"url\" with any whitespace after it and then a parens\n     (  = Start a capturing group\n       (?:  = Start a non-capturing group\n           [^)(]  = Match anything that isn't a parentheses\n           |  = OR\n           \\(  = Match a start parentheses\n               (?:  = Start another non-capturing groups\n                   [^)(]+  = Match anything that isn't a parentheses\n                   |  = OR\n                   \\(  = Match a start parentheses\n                       [^)(]*  = Match anything that isn't a parentheses\n                   \\)  = Match a end parentheses\n               )  = End Group\n               *\\) = Match anything and then a close parens\n           )  = Close non-capturing group\n           *  = Match anything\n        )  = Close capturing group\n   \\)  = Match a close parens\n  \t /gi  = Get all matches, not the first.  Be case insensitive.\n   */\n\n  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 change\n\n    if (/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/|\\s*$)/i.test(unquotedOrigUrl)) {\n      return fullMatch;\n    } // convert the url to a full url\n\n\n    var newUrl;\n\n    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 url\n      newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'\n    } else {\n      // path should be relative to current directory\n      newUrl = currentDir + unquotedOrigUrl.replace(/^\\.\\//, \"\"); // Strip leading './'\n    } // send back the fixed url(...)\n\n\n    return \"url(\" + JSON.stringify(newUrl) + \")\";\n  }); // send back the fixed css\n\n  return fixedCss;\n};","map":{"version":3,"sources":["/Users/andrewxia/Documents/work/codefold/example/node_modules/style-loader/lib/urls.js"],"names":["module","exports","css","location","window","Error","baseUrl","protocol","host","currentDir","pathname","replace","fixedCss","fullMatch","origUrl","unquotedOrigUrl","trim","o","$1","test","newUrl","indexOf","JSON","stringify"],"mappings":"AACA;;;;;;;;;;;;AAaAA,MAAM,CAACC,OAAP,GAAiB,UAAUC,GAAV,EAAe;AAC9B;AACA,MAAIC,QAAQ,GAAG,OAAOC,MAAP,KAAkB,WAAlB,IAAiCA,MAAM,CAACD,QAAvD;;AAEA,MAAI,CAACA,QAAL,EAAe;AACb,UAAM,IAAIE,KAAJ,CAAU,kCAAV,CAAN;AACD,GAN6B,CAQ/B;;;AACA,MAAI,CAACH,GAAD,IAAQ,OAAOA,GAAP,KAAe,QAA3B,EAAqC;AACnC,WAAOA,GAAP;AACA;;AAED,MAAII,OAAO,GAAGH,QAAQ,CAACI,QAAT,GAAoB,IAApB,GAA2BJ,QAAQ,CAACK,IAAlD;AACA,MAAIC,UAAU,GAAGH,OAAO,GAAGH,QAAQ,CAACO,QAAT,CAAkBC,OAAlB,CAA0B,WAA1B,EAAuC,GAAvC,CAA3B,CAd8B,CAgB/B;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAIC,QAAQ,GAAGV,GAAG,CAACS,OAAJ,CAAY,qDAAZ,EAAmE,UAASE,SAAT,EAAoBC,OAApB,EAA6B;AAC9G;AACA,QAAIC,eAAe,GAAGD,OAAO,CAC3BE,IADoB,GAEpBL,OAFoB,CAEZ,UAFY,EAEA,UAASM,CAAT,EAAYC,EAAZ,EAAe;AAAE,aAAOA,EAAP;AAAY,KAF7B,EAGpBP,OAHoB,CAGZ,UAHY,EAGA,UAASM,CAAT,EAAYC,EAAZ,EAAe;AAAE,aAAOA,EAAP;AAAY,KAH7B,CAAtB,CAF8G,CAO9G;;AACA,QAAI,oDAAoDC,IAApD,CAAyDJ,eAAzD,CAAJ,EAA+E;AAC7E,aAAOF,SAAP;AACD,KAV6G,CAY9G;;;AACA,QAAIO,MAAJ;;AAEA,QAAIL,eAAe,CAACM,OAAhB,CAAwB,IAAxB,MAAkC,CAAtC,EAAyC;AACtC;AACFD,MAAAA,MAAM,GAAGL,eAAT;AACA,KAHD,MAGO,IAAIA,eAAe,CAACM,OAAhB,CAAwB,GAAxB,MAAiC,CAArC,EAAwC;AAC9C;AACAD,MAAAA,MAAM,GAAGd,OAAO,GAAGS,eAAnB,CAF8C,CAEV;AACpC,KAHM,MAGA;AACN;AACAK,MAAAA,MAAM,GAAGX,UAAU,GAAGM,eAAe,CAACJ,OAAhB,CAAwB,OAAxB,EAAiC,EAAjC,CAAtB,CAFM,CAEsD;AAC5D,KAxB6G,CA0B9G;;;AACA,WAAO,SAASW,IAAI,CAACC,SAAL,CAAeH,MAAf,CAAT,GAAkC,GAAzC;AACA,GA5Bc,CAAf,CA1C+B,CAwE/B;;AACA,SAAOR,QAAP;AACA,CA1ED","sourcesContent":["\n/**\n * When source maps are enabled, `style-loader` uses a link element with a data-uri to\n * embed the css on the page. This breaks all relative urls because now they are relative to a\n * 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 */\n\nmodule.exports = function (css) {\n  // get current location\n  var location = typeof window !== \"undefined\" && window.location;\n\n  if (!location) {\n    throw new Error(\"fixUrls requires window.location\");\n  }\n\n\t// blank or null?\n\tif (!css || typeof css !== \"string\") {\n\t  return css;\n  }\n\n  var baseUrl = location.protocol + \"//\" + location.host;\n  var currentDir = baseUrl + location.pathname.replace(/\\/[^\\/]*$/, \"/\");\n\n\t// convert each url(...)\n\t/*\n\tThis regular expression is just a way to recursively match brackets within\n\ta string.\n\n\t /url\\s*\\(  = Match on the word \"url\" with any whitespace after it and then a parens\n\t   (  = Start a capturing group\n\t     (?:  = Start a non-capturing group\n\t         [^)(]  = Match anything that isn't a parentheses\n\t         |  = OR\n\t         \\(  = Match a start parentheses\n\t             (?:  = Start another non-capturing groups\n\t                 [^)(]+  = Match anything that isn't a parentheses\n\t                 |  = OR\n\t                 \\(  = Match a start parentheses\n\t                     [^)(]*  = Match anything that isn't a parentheses\n\t                 \\)  = Match a end parentheses\n\t             )  = End Group\n              *\\) = Match anything and then a close parens\n          )  = Close non-capturing group\n          *  = Match anything\n       )  = Close capturing group\n\t \\)  = Match a close parens\n\n\t /gi  = Get all matches, not the first.  Be case insensitive.\n\t */\n\tvar fixedCss = css.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi, function(fullMatch, origUrl) {\n\t\t// strip quotes (if they exist)\n\t\tvar unquotedOrigUrl = origUrl\n\t\t\t.trim()\n\t\t\t.replace(/^\"(.*)\"$/, function(o, $1){ return $1; })\n\t\t\t.replace(/^'(.*)'$/, function(o, $1){ return $1; });\n\n\t\t// already a full url? no change\n\t\tif (/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/|\\s*$)/i.test(unquotedOrigUrl)) {\n\t\t  return fullMatch;\n\t\t}\n\n\t\t// convert the url to a full url\n\t\tvar newUrl;\n\n\t\tif (unquotedOrigUrl.indexOf(\"//\") === 0) {\n\t\t  \t//TODO: should we add protocol?\n\t\t\tnewUrl = unquotedOrigUrl;\n\t\t} else if (unquotedOrigUrl.indexOf(\"/\") === 0) {\n\t\t\t// path should be relative to the base url\n\t\t\tnewUrl = baseUrl + unquotedOrigUrl; // already starts with '/'\n\t\t} else {\n\t\t\t// path should be relative to current directory\n\t\t\tnewUrl = currentDir + unquotedOrigUrl.replace(/^\\.\\//, \"\"); // Strip leading './'\n\t\t}\n\n\t\t// send back the fixed url(...)\n\t\treturn \"url(\" + JSON.stringify(newUrl) + \")\";\n\t});\n\n\t// send back the fixed css\n\treturn fixedCss;\n};\n"]},"metadata":{},"sourceType":"script"}