Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

source-map-loader

Package Overview
Dependencies
Maintainers
8
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source-map-loader - npm Package Compare versions

Comparing version 1.1.3 to 2.0.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.0.0](https://github.com/webpack-contrib/source-map-loader/compare/v1.1.3...v2.0.0) (2020-12-24)
### ⚠ BREAKING CHANGES
* minimum supported `webpack` version is `5`
### [1.1.3](https://github.com/webpack-contrib/source-map-loader/compare/v1.1.2...v1.1.3) (2020-12-04)

@@ -7,0 +14,0 @@

10

dist/index.js

@@ -10,6 +10,2 @@ "use strict";

var _loaderUtils = require("loader-utils");
var _schemaUtils = require("schema-utils");
var _options = _interopRequireDefault(require("./options.json"));

@@ -26,7 +22,3 @@

async function loader(input, inputMap) {
const options = (0, _loaderUtils.getOptions)(this);
(0, _schemaUtils.validate)(_options.default, options, {
name: "Source Map Loader",
baseDataPath: "options"
});
const options = this.getOptions(_options.default);
const {

@@ -33,0 +25,0 @@ sourceMappingURL,

{
"title": "Source Map Loader options",
"type": "object",

@@ -3,0 +4,0 @@ "additionalProperties": false,

@@ -8,8 +8,53 @@ "use strict";

var _whatwgMimetype = _interopRequireDefault(require("whatwg-mimetype"));
var _abab = require("abab");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const removeLeadingAndTrailingHTTPWhitespace = string => string.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
const removeTrailingHTTPWhitespace = string => string.replace(/[ \t\n\r]+$/, "");
const isHTTPWhitespaceChar = char => char === " " || char === "\t" || char === "\n" || char === "\r";
const solelyContainsHTTPTokenCodePoints = string => /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/.test(string);
const soleyContainsHTTPQuotedStringTokenCodePoints = string => /^[\t\u0020-\u007E\u0080-\u00FF]*$/.test(string);
const asciiLowercase = string => string.replace(/[A-Z]/g, l => l.toLowerCase());
const collectAnHTTPQuotedString = (input, position) => {
let value = ""; // eslint-disable-next-line no-param-reassign
position += 1; // eslint-disable-next-line no-constant-condition
while (true) {
while (position < input.length && input[position] !== '"' && input[position] !== "\\") {
value += input[position]; // eslint-disable-next-line no-param-reassign
position += 1;
}
if (position >= input.length) {
break;
}
const quoteOrBackslash = input[position]; // eslint-disable-next-line no-param-reassign
position += 1;
if (quoteOrBackslash === "\\") {
if (position >= input.length) {
value += "\\";
break;
}
value += input[position]; // eslint-disable-next-line no-param-reassign
position += 1;
} else {
break;
}
}
return [value, position];
};
function isASCIIHex(c) {

@@ -58,10 +103,10 @@ return c >= 0x30 && c <= 0x39 || c >= 0x41 && c <= 0x46 || c >= 0x61 && c <= 0x66;

let position = 0;
let mimeType = "";
let mediaType = "";
while (position < input.length && input[position] !== ",") {
mimeType += input[position];
mediaType += input[position];
position += 1;
}
mimeType = mimeType.replace(/^[ \t\n\f\r]+/, "").replace(/[ \t\n\f\r]+$/, "");
mediaType = mediaType.replace(/^[ \t\n\f\r]+/, "").replace(/[ \t\n\f\r]+$/, "");

@@ -76,3 +121,3 @@ if (position === input.length) {

const mimeTypeBase64MatchResult = /(.*); *[Bb][Aa][Ss][Ee]64$/.exec(mimeType);
const mimeTypeBase64MatchResult = /(.*); *[Bb][Aa][Ss][Ee]64$/.exec(mediaType);

@@ -88,21 +133,113 @@ if (mimeTypeBase64MatchResult) {

body = Buffer.from(asString, "binary");
[, mimeType] = mimeTypeBase64MatchResult;
[, mediaType] = mimeTypeBase64MatchResult;
}
if (mimeType.startsWith(";")) {
mimeType = `text/plain ${mimeType}`;
if (mediaType.startsWith(";")) {
mediaType = `text/plain ${mediaType}`;
}
let mimeTypeRecord;
const result = {
// eslint-disable-next-line no-undefined
type: undefined,
// eslint-disable-next-line no-undefined
subtype: undefined,
parameters: new Map(),
isBase64: Boolean(mimeTypeBase64MatchResult),
body
};
try {
mimeTypeRecord = new _whatwgMimetype.default(mimeType);
} catch (e) {
mimeTypeRecord = new _whatwgMimetype.default("text/plain;charset=US-ASCII");
if (!mediaType) {
return result;
}
return {
mimeType: mimeTypeRecord,
body
};
const inputMediaType = removeLeadingAndTrailingHTTPWhitespace(mediaType);
let positionMediaType = 0;
let type = "";
while (positionMediaType < inputMediaType.length && inputMediaType[positionMediaType] !== "/") {
type += inputMediaType[positionMediaType];
positionMediaType += 1;
}
if (type.length === 0 || !solelyContainsHTTPTokenCodePoints(type)) {
return result;
}
if (positionMediaType >= inputMediaType.length) {
return result;
} // Skips past "/"
positionMediaType += 1;
let subtype = "";
while (positionMediaType < inputMediaType.length && inputMediaType[positionMediaType] !== ";") {
subtype += inputMediaType[positionMediaType];
positionMediaType += 1;
}
subtype = removeTrailingHTTPWhitespace(subtype);
if (subtype.length === 0 || !solelyContainsHTTPTokenCodePoints(subtype)) {
return result;
}
result.type = asciiLowercase(type);
result.subtype = asciiLowercase(subtype);
while (positionMediaType < inputMediaType.length) {
// Skip past ";"
positionMediaType += 1;
while (isHTTPWhitespaceChar(inputMediaType[positionMediaType])) {
positionMediaType += 1;
}
let parameterName = "";
while (positionMediaType < inputMediaType.length && inputMediaType[positionMediaType] !== ";" && inputMediaType[positionMediaType] !== "=") {
parameterName += inputMediaType[positionMediaType];
positionMediaType += 1;
}
parameterName = asciiLowercase(parameterName);
if (positionMediaType < inputMediaType.length) {
if (inputMediaType[positionMediaType] === ";") {
// eslint-disable-next-line no-continue
continue;
} // Skip past "="
positionMediaType += 1;
}
let parameterValue = "";
if (inputMediaType[positionMediaType] === '"') {
[parameterValue, positionMediaType] = collectAnHTTPQuotedString(inputMediaType, positionMediaType);
while (positionMediaType < inputMediaType.length && inputMediaType[positionMediaType] !== ";") {
positionMediaType += 1;
}
} else {
while (positionMediaType < inputMediaType.length && inputMediaType[positionMediaType] !== ";") {
parameterValue += inputMediaType[positionMediaType];
positionMediaType += 1;
}
parameterValue = removeTrailingHTTPWhitespace(parameterValue);
if (parameterValue === "") {
// eslint-disable-next-line no-continue
continue;
}
}
if (parameterName.length > 0 && solelyContainsHTTPTokenCodePoints(parameterName) && soleyContainsHTTPQuotedStringTokenCodePoints(parameterValue) && !result.parameters.has(parameterName)) {
result.parameters.set(parameterName, parameterValue);
}
}
return result;
}

@@ -18,4 +18,2 @@ "use strict";

var _loaderUtils = require("loader-utils");
var _parseDataUrl = _interopRequireDefault(require("./parse-data-url"));

@@ -93,5 +91,3 @@

function getAbsolutePath(context, url, sourceRoot) {
const request = (0, _loaderUtils.urlToRequest)(url, true);
function getAbsolutePath(context, request, sourceRoot) {
if (sourceRoot) {

@@ -102,3 +98,3 @@ if (_path.default.isAbsolute(sourceRoot)) {

return _path.default.join(context, (0, _loaderUtils.urlToRequest)(sourceRoot, true), request);
return _path.default.join(context, sourceRoot, request);
}

@@ -113,4 +109,6 @@

if (dataURL) {
dataURL.encodingName = labelToName(dataURL.mimeType.parameters.get("charset")) || "UTF-8";
return (0, _iconvLite.decode)(dataURL.body, dataURL.encodingName);
// https://tools.ietf.org/html/rfc4627
// JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
const encodingName = labelToName(dataURL.parameters.get("charset")) || "UTF-8";
return (0, _iconvLite.decode)(dataURL.body, encodingName);
}

@@ -117,0 +115,0 @@

{
"name": "source-map-loader",
"version": "1.1.3",
"version": "2.0.0",
"description": "extracts inlined source map and offers it to webpack",

@@ -41,3 +41,3 @@ "license": "MIT",

"peerDependencies": {
"webpack": "^4.0.0 || ^5.0.0"
"webpack": "^5.0.0"
},

@@ -47,11 +47,8 @@ "dependencies": {

"iconv-lite": "^0.6.2",
"loader-utils": "^2.0.0",
"schema-utils": "^3.0.0",
"source-map": "^0.6.1",
"whatwg-mimetype": "^2.3.0"
"source-map": "^0.6.1"
},
"devDependencies": {
"@babel/cli": "^7.12.8",
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@commitlint/cli": "^11.0.0",

@@ -65,8 +62,8 @@ "@commitlint/config-conventional": "^11.0.0",

"del-cli": "^3.0.1",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-import": "^2.22.1",
"husky": "^4.3.0",
"husky": "^4.3.6",
"jest": "^26.6.3",
"lint-staged": "^10.5.2",
"lint-staged": "^10.5.3",
"memfs": "^3.2.0",

@@ -76,3 +73,3 @@ "npm-run-all": "^4.1.5",

"standard-version": "^9.0.0",
"webpack": "^5.9.0"
"webpack": "^5.11.0"
},

@@ -79,0 +76,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc