This repository was archived by the owner on Sep 21, 2021. It is now read-only.
Compute sourceRoot when only relative URLs are seen#698
Merged
tromey merged 1 commit intofirefox-devtools:masterfrom Sep 20, 2017
Merged
Compute sourceRoot when only relative URLs are seen#698tromey merged 1 commit intofirefox-devtools:masterfrom
tromey merged 1 commit intofirefox-devtools:masterfrom
Conversation
jasonLaster
reviewed
Sep 19, 2017
Contributor
jasonLaster
left a comment
There was a problem hiding this comment.
Hmm, i think i might have seen this popup in a real world example:
| // URLs are relative. What's difficult is that we want to pretend | ||
| // that some non-URLs, like "webpack:/whatever", are actually URLs. | ||
| if (sourceMap.hasContentsOfAllSources() && | ||
| sourceMap.sources.every(sourceName => URL_ISH.test(sourceName))) { |
Contributor
There was a problem hiding this comment.
this is minor, but can we move this to a temporary variable so that it is a bit more self documenting
const allURLsAreAbsolute = sourceMap.sources.every(sourceName => URL_ISH.test(sourceName)| test("Non-existing sourceRoot resolution with relative URLs", async () => { | ||
| const urls = await setupBundleFixture("noroot2"); | ||
| expect(urls).toEqual(["http://example.com/heart.js"]); | ||
| }); |
Contributor
There was a problem hiding this comment.
i'm not really sure what this test is documenting. It might be nice to see the webpack example in a test as well.
Contributor
Author
There was a problem hiding this comment.
The other tests cover webpack -- I initially wrote my patch a different way, which is how I knew that I needed to do this regexp thing.
Do you want some other change here as well?
Currently _setSourceMapRoot bails if the source map contains all the sources. However, this is not valid according to the source map spec; and the debugger doesn't work properly with the returned URLs. On the other hand, some source maps have non-URLs like "webpack:/bootstrap", which we do want to treat as absolute. So, this patch works around the problem by examining the URLs in a mildly lax way. Fixes firefox-devtools#356
286a8b0 to
c72ecf4
Compare
jasonLaster
approved these changes
Sep 20, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently _setSourceMapRoot bails if the source map contains all the
sources. However, this is not valid according to the source map spec;
and the debugger doesn't work properly with the returned URLs. On the
other hand, some source maps have non-URLs like "webpack:/bootstrap",
which we do want to treat as absolute. So, this patch works around
the problem by examining the URLs in a mildly lax way.
Fixes #356
Associated Issue: #
Summary of Changes
Test Plan
Tell us a little a bit about how you tested your patch.
Example test plan:
Screenshots/Videos (OPTIONAL)