Fix support for absolute urls in sourceMappingURL by pfhayes · Pull Request #332 · evanw/node-source-map-support · GitHub
Skip to content

Fix support for absolute urls in sourceMappingURL#332

Open
pfhayes wants to merge 3 commits into
evanw:masterfrom
pfhayes:fix-absolute-urls
Open

Fix support for absolute urls in sourceMappingURL#332
pfhayes wants to merge 3 commits into
evanw:masterfrom
pfhayes:fix-absolute-urls

Conversation

@pfhayes

@pfhayes pfhayes commented Jun 30, 2023

Copy link
Copy Markdown

Previously, supportRelativeURL would return an invalid response if both file and url were absolute.

sourceMapSupport.supportRelativeURL(
    'http://127.0.0.1:1336/chunk/chunk.js',
    'http://127.0.0.1:1336/chunk/chunk.js.map'
);
// Returns 'http://127.0.0.1:1336/chunk/http:/127.0.0.1:1336/chunk/chunk.js.map'

As a result, retrieveSourceMap would do the wrong thing when used in the browser on source maps with absolute URLs. This adds support.

I added a test but it wasn't clear to me how to update the test environment to support this. Instead, I just exposed the method for testing. I am open to feedback on how this could be improved.

@0xAverageUser

0xAverageUser commented Jul 14, 2023

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants