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

source-map-url

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source-map-url - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

LICENSE

2

bower.json
{
"name": "source-map-url",
"version": "0.3.0",
"version": "0.4.0",
"author": "Simon Lydell",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -0,1 +1,11 @@

### Version 0.4.0 (2015-11-12) ###
- Changed: sourceMappingURL comments used to be matched only when placed at
the end of the script. However, since several commonly used JavaScript
libraries do not follow this convention and all popular web browsers accept
non-trailing comments, this has been revised.
So now non-trailing SourceMappingURL comments are matched as well.
### Version 0.3.0 (2014-08-16) ###

@@ -2,0 +12,0 @@

{
"name": "source-map-url",
"version": "0.3.0",
"version": "0.4.0",
"author": "Simon Lydell",

@@ -18,2 +18,2 @@ "license": "MIT",

]
}
}
{
"name": "source-map-url",
"version": "0.3.0",
"version": "0.4.0",
"author": "Simon Lydell",

@@ -39,2 +39,2 @@ "license": "MIT",

}
}
}

@@ -77,4 +77,4 @@ Overview [![Build Status](https://travis-ci.org/lydell/source-map-url.png?branch=master)](https://travis-ci.org/lydell/source-map-url)

Lets you append something to a file without worrying about breaking the
sourceMappingURL comment (which needs to be at the end of the file).
Lets you append something to a file without worrying about burying the
sourceMappingURL comment (by keeping it at the end of the file).

@@ -81,0 +81,0 @@ ### `sourceMappingURL.regex` ###

@@ -26,3 +26,3 @@ // Copyright 2014 Simon Lydell

")" +
"\\s*$"
"\\s*"
)

@@ -29,0 +29,0 @@

@@ -32,2 +32,30 @@ // Copyright 2014 Simon Lydell

var nonTrailingComments = {
jsLeading: {
contents: [
"//# sourceMappingURL=foo.js.map",
"(function(){})"
],
solution: [
"(function(){})"
]
},
mixEmbedded: {
contents: [
"/*! Library Name v1.0.0",
"//# sourceMappingURL=foo.js.map",
"*/",
"(function(){})"
],
solution: [
"/*! Library Name v1.0.0",
"*/",
"(function(){})"
]
}
}
function forEachComment(fn) {

@@ -41,2 +69,19 @@ forOf(comments, function(name, comment) {

function forEachNonTrailingComment(fn) {
forOf(nonTrailingComments, function(name, comment) {
var description = "the '" + name + "' syntax with "
fn({
contents: comment.contents.join("\n"),
solution: comment.solution.join("\n")
}, description + "regular newlines")
fn({
contents: comment.contents.join("\r\n"),
solution: comment.solution.join("\r\n")
}, description + "Windows newlines")
})
}
function forOf(obj, fn) {

@@ -70,3 +115,18 @@ for (var key in obj) {

forEachNonTrailingComment(function(comment, description) {
it("gets the url from " + description, function() {
expect(sourceMappingURL.getFrom("code\n" + comment.contents))
.to.equal("foo.js.map")
expect(sourceMappingURL.getFrom("code" + comment.contents))
.to.equal("foo.js.map")
expect(sourceMappingURL.getFrom(comment.contents))
.to.equal("foo.js.map")
})
})
it("returns null if no comment", function() {

@@ -110,3 +170,18 @@ expect(sourceMappingURL.getFrom("code"))

forEachNonTrailingComment(function(comment, description) {
it("returns true for " + description, function() {
expect(sourceMappingURL.existsIn("code\n" + comment.contents))
.to.equal(true)
expect(sourceMappingURL.existsIn("code" + comment.contents))
.to.equal(true)
expect(sourceMappingURL.existsIn(comment.contents))
.to.equal(true)
})
})
it("returns false if no comment", function() {

@@ -144,3 +219,18 @@ expect(sourceMappingURL.existsIn("code"))

forEachNonTrailingComment(function(comment, description) {
it("removes the comment for " + description, function() {
expect(sourceMappingURL.removeFrom("code\n" + comment.contents))
.to.equal("code\n" + comment.solution)
expect(sourceMappingURL.removeFrom("code" + comment.contents))
.to.equal("code" + comment.solution)
expect(sourceMappingURL.removeFrom(comment.contents))
.to.equal(comment.solution)
})
})
it("does nothing if no comment", function() {

@@ -179,2 +269,18 @@ expect(sourceMappingURL.removeFrom("code\n"))

it("inserts a string before an embedded comment", function() {
expect(sourceMappingURL.insertBefore("/*! Library Name v1.0.0\n" +
"//# sourceMappingURL=foo.js.map\n*/\n(function(){})", "code\n"))
.to.equal("/*! Library Name v1.0.0\ncode\n" +
"//# sourceMappingURL=foo.js.map\n*/\n(function(){})")
})
it("inserts a string before a leading comment", function() {
expect(sourceMappingURL.insertBefore("//# sourceMappingURL=foo.js.map\n" +
"(function(){})", "code\n"))
.to.equal("code\n//# sourceMappingURL=foo.js.map\n" +
"(function(){})")
})
it("appends if no comment", function() {

@@ -229,16 +335,2 @@ expect(sourceMappingURL.insertBefore("code", "\nmore code"))

it("only matches " + description + " at the end of files", function() {
noMatch("code\n" + comment + " code")
noMatch("code" + comment + " code")
noMatch("code\n" + comment + "\ncode")
noMatch("code" + comment + "\ncode")
noMatch("code\n" + comment + "\n// Generated by foobar")
noMatch("code" + comment + "\n// Generated by foobar")
noMatch("alert\n('\\" + comment + "')")
noMatch("alert('\\" + comment + "')")
noMatch('alert\n("\\' + comment + '")')
noMatch('alert("\\' + comment + '")')
})
})

@@ -253,13 +345,2 @@

noMatch(
"/*\n" +
" //# sourceMappingURL=foo\n" +
"*/"
)
noMatch(
"/*//# sourceMappingURL=foo\n" +
"*/"
)
noMatch(
"// # sourceMappingURL=foo"

@@ -266,0 +347,0 @@ )

Sorry, the diff of this file is not supported yet

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