-
Notifications
You must be signed in to change notification settings - Fork 135
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
refactor!: remove ufo
dependency
#440
Draft
johannschopplich
wants to merge
5
commits into
unjs:main
Choose a base branch
from
johannschopplich:refactor/native-url
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cc714ee
feat!: replace `ufo` with native `URL` utils
johannschopplich 997afbb
fix: reduce `URL` usage and fix tests
johannschopplich ad22663
refactor: share `http://localhost` string
johannschopplich d7075be
perf: drop `URL` usage in `withQuery`
johannschopplich 8478387
perf: return early if no query params in input URL
johannschopplich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
perf: drop
URL
usage in withQuery
- Loading branch information
commit d7075bebf2034c9f60ead847b70b4f7254605c30
There are no files selected for viewing
This file contains 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
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.
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.
fast-path: when there is no searchIndex we can avoid creating new
URLSearchParams
(sorry for being strict this is kind of thing we forget later and it can be potentially bases toufo/lite
trying to make sure optimizing it as much as we can)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.
Sorry, I don't get it completely: Even if no search is in the input path, we still need to construct the encoded query string for the new output path, am I right?
How should we build the search params if not using
URLSearchParams
? Port thestringifyQuery
function fromufo
?P.S.: Of course, no need to justify optimization and future-proofness. 🙋♂️
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.
Sorry my wording was confusing. I meant that when there is no quesry in input string, we can have a fast path if block. So we don't need to iterate to for example remove
undefined
values, etc (we already know query state is empty) so it can be something likereturn new URLSearchParams(query).toString
(I'm not sure if query object needs normalization but it could be simple map)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.
Ahh, I get it now! Thanks for the clarification. Now:
query
object.Is that what you intended?
We have to normalize the values for
URLSearchParams
, otherwise it returns string likekey=undefined
. I have again tested with the (slighty changed)ufo
tests. I will create a separate PR there to track the implementation of these lighter functions.