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

sourcemap-validator

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sourcemap-validator - npm Package Compare versions

Comparing version 0.0.5 to 1.0.0

.npmignore

37

index.js
var validate
, validateMapping
, toAscii
, assert = require('assert')

@@ -9,2 +10,16 @@ , SMConsumer = require('source-map').SourceMapConsumer

// Lifted from UglifyJS
toAscii = function (str, identifier) {
return str.replace(/[\u0080-\uffff]/g, function(ch) {
var code = ch.charCodeAt(0).toString(16);
if (code.length <= 2 && !identifier) {
while (code.length < 2) code = "0" + code;
return "\\x" + code;
} else {
while (code.length < 4) code = "0" + code;
return "\\u" + code;
}
}).replace(/\x0B/g, "\\x0B");
};
// Performs simple validation of a mapping

@@ -26,3 +41,3 @@ validateMapping = function (mapping) {

// Validates an entire sourcemap
validate = function (srcs, min, map, opts) {
validate = function (min, map, srcs) {
var consumer

@@ -32,2 +47,18 @@ , mappingCount = 0

srcs = srcs || {};
// If no map was given, try to extract it from min
if(map == null) {
try {
var marker = '//@ sourceMappingURL=data:application/json;base64,'
, offset = min.indexOf(marker);
map = (new Buffer(min.substring(offset + marker.length), 'base64')).toString();
min = min.substring(0, offset);
}
catch (e) {
throw new Error('No map argument provided, and no inline sourcemap found');
}
}
try {

@@ -46,4 +77,2 @@ consumer = new SMConsumer(map)

opts = opts || {};
each(srcs, function (src, file) {

@@ -77,3 +106,5 @@ return splitSrcs[file] = src.split('\n'); // Split sources by line

, '\'' + jsesc(mapping.name) + '\''
, '\'' + toAscii(mapping.name) + '\''
, '"' + jsesc(mapping.name, {quotes: 'double'}) + '"'
, '"' + toAscii(mapping.name) + '"'
];

@@ -80,0 +111,0 @@

6

package.json

@@ -14,3 +14,3 @@ {

],
"version": "0.0.5",
"version": "1.0.0",
"repository": {

@@ -30,3 +30,3 @@ "type": "git",

"devDependencies": {
"uglify-js": "https://github.com/ben-ng/UglifyJS2/archive/sourcemap-offset-fix.tar.gz",
"uglify-js": "2.4.x",
"jake": "0.7.x"

@@ -36,4 +36,4 @@ },

"engines": {
"node": "0.8.x"
"node": "0.10.x"
}
}
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