-
Notifications
You must be signed in to change notification settings - Fork 75
fix: Importing files using a resource query #55
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,8 @@ function evalDependencyGraph({loaderContext, src, filename, publicPath = ""}) { | |
| exports, | ||
| __webpack_public_path__: publicPath, // eslint-disable-line camelcase | ||
| require: givenRelativePath => { | ||
| const indexOfQuery = Math.max(givenRelativePath.indexOf("?"), givenRelativePath.length); | ||
| const noDoubleQuestionMarkPath = givenRelativePath.replace(/\?\?/g, "##"); | ||
| const indexOfQuery = noDoubleQuestionMarkPath.includes("?") ? noDoubleQuestionMarkPath.indexOf("?") : givenRelativePath.length; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A shorter way of accomplishing the same thing is: const indexOfQuery = givenRelativePath.search(/(\?.*)?$/);
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love it but code is meant to be readable and understandable. I'm going to leave the decision to the maintainer. |
||
| const relativePathWithoutQuery = givenRelativePath.slice(0, indexOfQuery); | ||
| const indexOfLastExclMark = relativePathWithoutQuery.lastIndexOf("!"); | ||
| const query = givenRelativePath.slice(indexOfQuery); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is
??part of a valid url? Also if you handled??, why didn't you also handle????I don't think you need to handle these anyways. You should just focus on fixing the query part which was handled wrongly in the original code and leave these other cases to the judgement of the person using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a test case failing, it was related to double question mark. I believe it is valid in webpack context.