From fcac27c2833133a2734f7d20de98f21a2e7608ac Mon Sep 17 00:00:00 2001 From: Tim Oxley Date: Wed, 13 May 2015 16:43:55 +0800 Subject: [PATCH] Check for 200 response code. Without this check, missing sourcemaps cause the package to continue as if the 404 message is the sourcemap, leading to crashes when responses like "Not Found" cannot be parsed as source maps. --- source-map-support.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source-map-support.js b/source-map-support.js index 07048d8..e2126b2 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -29,7 +29,10 @@ function retrieveFile(path) { var xhr = new XMLHttpRequest(); xhr.open('GET', path, false); xhr.send(null); - var contents = xhr.readyState === 4 ? xhr.responseText : null; + var contents = null + if (xhr.readyState === 4 && xhr.status === 200) { + contents = xhr.responseText + } } // Otherwise, use the filesystem