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

combine-source-map

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

combine-source-map - npm Package Compare versions

Comparing version 0.5.0 to 0.6.1

lib/path-is-absolute.js

18

index.js

@@ -5,9 +5,8 @@ 'use strict';

var convert = require('convert-source-map');
var memoize = require('lodash.memoize');
var createGenerator = require('inline-source-map');
var pathIsAbsolute = require('./lib/path-is-absolute');
var mappingsFromMap = require('./lib/mappings-from-map');
function isAbsolutePath(p) {
return /^(?:\/|[a-z]+:\/\/)/.test(p)
|| path.resolve(p) == path.normalize(p);
}
var protocolRx = /^[a-z]+:\/\//;

@@ -31,3 +30,3 @@ /**

*/
function rebaseRelativePath(sourceFile, relativeRoot, relativePath) {
var rebaseRelativePath = memoize(function(sourceFile, relativeRoot, relativePath) {
if (!relativePath) {

@@ -40,4 +39,5 @@ return relativePath;

// absolute path does not need rebasing
if (isAbsolutePath(relativeRootedPath)) {
if (sourceFile === relativeRootedPath || // same path,
pathIsAbsolute(relativeRootedPath) || // absolute path, nor
protocolRx.test(relativeRootedPath)) { // absolute protocol need rebasing
return relativeRootedPath;

@@ -48,3 +48,5 @@ }

return path.join(path.dirname(sourceFile), relativeRootedPath);
}
}, function(a, b, c) {
return a + '::' + b + '::' + c;
});

@@ -51,0 +53,0 @@ function resolveMap(source) {

{
"name": "combine-source-map",
"version": "0.5.0",
"version": "0.6.1",
"description": "Add source maps of multiple files, offset them and then combine them into one source map",

@@ -15,5 +15,6 @@ "main": "index.js",

"dependencies": {
"convert-source-map": "~1.1.0",
"inline-source-map": "~0.5.0",
"convert-source-map": "~0.3.0",
"source-map": "~0.1.31"
"lodash.memoize": "~3.0.3",
"source-map": "~0.4.2"
},

@@ -20,0 +21,0 @@ "devDependencies": {

@@ -281,2 +281,50 @@ 'use strict';

test('relative path when source and file name are the same', function(t) {
var gen1Map = {
version: 3,
sources: [ 'a/b/one.js' ],
names: [],
mappings: 'AAAA',
file: 'a/b/one.js',
sourcesContent: [ 'console.log(1);\n' ]
};
var gen2Map = {
version: 3,
sources: [ 'a/b/two.js' ],
names: [],
mappings: 'AAAA',
file: 'a/b/two.js',
sourcesContent: [ 'console.log(2);\n' ]
};
var base64 = combine.create()
.addFile({
source: 'console.log(1);\n' + convert.fromObject(gen1Map).toComment(),
sourceFile: 'a/b/one.js'
})
.addFile({
source: 'console.log(2);\n' + convert.fromObject(gen2Map).toComment(),
sourceFile: 'a/b/two.js'
}, {line: 1})
.base64()
var sm = convert.fromBase64(base64).toObject();
t.deepEqual(sm.sources, ['a/b/one.js', 'a/b/two.js'],
'include the correct source');
t.deepEqual(
mappingsFromMap(sm)
, [ { original: { column: 0, line: 1 },
generated: { column: 0, line: 1 },
source: 'a/b/one.js',
name: undefined },
{ original: { column: 0, line: 1 },
generated: { column: 0, line: 2 },
source: 'a/b/two.js',
name: undefined } ], 'should properly map multiple files');
t.end()
});
test('remove comments', function (t) {

@@ -283,0 +331,0 @@ var mapComment = convert.fromObject(foo).toComment();

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