Skip to content
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

Normalize all URLs to be as absolute as possible to avoid usage of 'util.relative'. #366

Merged
merged 1 commit into from
Nov 13, 2018

Conversation

loganfsmyth
Copy link
Contributor

The consumer currently uses util.relative to take a URL and convert it to one that may be present in _sources. There are a few downsides to this approach:

  • We have to normalize sources or else risk not finding the match
  • We have to ensure that the sources conform to the expectation of relative URLs
  • The usage of relative makes it unclear whether argument URLs are expected to be relative to the map, or the root, or either.
  • We have to special-case 'sources' that just aren't relative, like sources: ['/a.js'] (which is also only special-cased on in sourceContentFor)

This patch centralizes all source lookups for the consumer in _findSourceIndex so that all APIs behave consistently. By converting all input paths to be as absolute as we can make them, we avoid the complexities of making URLs relative to one another, and it helps make clear how these behave.

@tromey
Copy link
Contributor

tromey commented Oct 16, 2018

I think I tried this once before, and there was some problem, but I can't remember what it might have been. I was thinking that maybe it made reverse lookups fail? But it seems like that can't be the case as long as the caller passes in the absolute URL of the original source. Perhaps it was that, though, but in the situation where aSourceMapURL is not specified? (Though I tend to think that this should be mandatory and not optional...)

Anyway I think this is reasonable. Thanks for the patch.

Copy link
Contributor

@tromey tromey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@loganfsmyth loganfsmyth merged commit b1653ca into simplify-section-consumer Nov 13, 2018
@loganfsmyth loganfsmyth deleted the normalize-consumer-urls branch November 13, 2018 22:59
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