Socket
Socket
Sign inDemoInstall

loader-utils

Package Overview
Dependencies
1
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.2.2

34

index.js

@@ -53,2 +53,36 @@ var JSON5 = require("json5");

return request.join("!");
};
exports.isUrlRequest = function(url, root) {
// An URL is not an request if
// 1. it's a Data Url
// 2. it's an absolute url or and protocol-relative
// 3. it's some kind of url for a template
if(/^data:|^(https?:)?\/\/|^[\{\}\[\]#*;,'§\$%&\(=?`´\^°<>]/.test(url)) return false;
// 4. It's also not an request if root isn't set and it's a root-relative url
if((root === undefined || root === false) && /^\//.test(url)) return false;
return true;
};
exports.urlToRequest = function(url, root) {
if(/^[^?]*~/.test(url)) {
// A `~` makes the url an module
return url.replace(/^[^?]*~/, "");
} else if(root !== undefined && root !== false && /^\//.test(url)) {
// if root is set and the url is root-relative
switch(typeof root) {
// 1. root is a string: root is prefixed to the url
case "string": return root + url;
// 2. root is `true`: absolute paths are allowed
// *nix only, windows-style absolute paths are always allowed as they doesn't start with a `/`
case "boolean": return url;
}
} else if(/^\.\.?\//.test(url)) {
// A relative url stays
return url;
} else {
// every other url is threaded like a relative url
return "./"+url;
}
throw new Error("Unexpected parameters to loader-utils 'urlToRequest': url = " + url + ", root = " + root + ".");
};

2

package.json
{
"name": "loader-utils",
"version": "0.2.1",
"version": "0.2.2",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "utils for webpack loaders",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc