Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions lib/source-map-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2014 Simon Lydell
// X11 (“MIT”) Licensed. (See LICENSE.)
// copied from https://github.com/lydell/source-map-url/blob/4106e5f0b001918790e3b830d2541252ba025a3d/source-map-url.js
// adapted to remove umd
/* eslint-disable no-var */

var innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/

var regex = RegExp(
"(?:" +
"/\\*" +
"(?:\\s*\r?\n(?://)?)?" +
"(?:" + innerRegex.source + ")" +
"\\s*" +
"\\*/" +
"|" +
"//(?:" + innerRegex.source + ")" +
")" +
"\\s*"
)

module.exports = {
regex: regex,
_innerRegex: innerRegex,

getFrom: function(code) {
var match = code.match(regex)
return (match ? match[1] || match[2] || "" : null)
},

existsIn: function(code) {
return regex.test(code)
},

removeFrom: function(code) {
return code.replace(regex, "")
},

insertBefore: function(code, string) {
var match = code.match(regex)
if (match) {
return code.slice(0, match.index) + string + code.slice(match.index)
} else {
return code + string
}
}
}
2 changes: 1 addition & 1 deletion lib/source-map.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const fs = require('fs-extra');
const srcURL = require('source-map-url');
const srcURL = require('./source-map-url');
const path = require('path');
const MemoryStreams = require('memory-streams');
const Coder = require('./coder');
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"heimdalljs-logger": "^0.1.9",
"memory-streams": "^0.1.3",
"mkdirp": "^0.5.0",
"@jacobq/source-map": "^1.1.0",
"source-map-url": "^0.3.0"
"@jacobq/source-map": "^1.1.0"
},
"devDependencies": {
"chai": "^4.1.2",
Expand Down
Loading
Loading