Skip to content

Fix RangeError on large files #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions source-map-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ function retrieveSourceMapURL(source) {

// Get the URL of the source map
fileData = retrieveFile(source);
var re = /\/\/[#@]\s*sourceMappingURL=([^'"]+)\s*$/mg;
var re = /\/\/[#@]\s*sourceMappingURL=/mg;
// Keep executing the search to find the *last* sourceMappingURL to avoid
// picking up sourceMappingURLs from comments, strings, etc.
var lastMatch, match;
while (match = re.exec(fileData)) lastMatch = match;
if (!lastMatch) return null;
return lastMatch[1];

var begin = lastMatch.index + lastMatch[0].length;
var end = fileData.indexOf("\n", begin);
if (end < 0) end = fileData.length;
while (end > begin && fileData[end - 1].match(/\s/)) end--;

return fileData.substring(begin, end);
};

// Can be overridden by the retrieveSourceMap option to install. Takes a
Expand Down