rarecoil/unwebpack-sourcemap

Unable to handle urls that start with // and crash when returning False from _parse_sourcemap

tar-xvf opened this issue · 2 comments

Here is a small patch that fixes the two issues.

@@ -91,7 +91,7 @@ class SourceMapExtractor(object):
     def _parse_remote_sourcemap(self, uri):
         """GET a remote sourcemap and parse it."""
         data = self._get_remote_data(uri)
-        if data is not None:
+        if data is not None and data:
             self._parse_sourcemap(data, True)
         else:
             print("WARNING: Could not retrieve sourcemap from URI %s" % uri)
@@ -116,6 +116,8 @@ class SourceMapExtractor(object):
             next_target_uri = ""
             if parsed_uri.scheme != '':
                 next_target_uri = source
+            elif source.startswith("//"):
+                next_target_uri = urlparse(uri).scheme + ":" + source
             else:
                 current_uri = urlparse(uri)
                 built_uri = current_uri.scheme + "://" + current_uri.netloc + source

It seems that #7 fixes this same issue, so I will close this and look there.

Looks like the data is not None and data doesn't actually exist in that PR, so reopening so I can add that