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'. #365

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.

@loganfsmyth loganfsmyth requested a review from tromey October 15, 2018 18:01
@loganfsmyth
Copy link
Contributor Author

Woops, didn't quite post what I meant to. Closing in favor of #366

@loganfsmyth loganfsmyth deleted the normalize-consumer-urls branch October 15, 2018 18:05
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.

1 participant