-
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
Conversation
|
Please merge this. Very useful |
| __webpack_public_path__: publicPath, // eslint-disable-line camelcase | ||
| require: givenRelativePath => { | ||
| const indexOfQuery = givenRelativePath.includes("?") ? givenRelativePath.indexOf("?") : givenRelativePath.length; | ||
| const noDoubleQuestionMarkPath = givenRelativePath.replace(/\?\?/g, "##"); |
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.
| require: givenRelativePath => { | ||
| const indexOfQuery = givenRelativePath.includes("?") ? 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 comment
The 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(/(\?.*)?$/);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.
I love it but code is meant to be readable and understandable. I'm going to leave the decision to the maintainer.
|
Fixed in #66. |
#53