-
Notifications
You must be signed in to change notification settings - Fork 4.7k
URL: Remove all of Lodash from the package #41687
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a7ede97
url: Introduce remove-accents dependency
tyxla 16afd37
url: Use removeAccents instead of lodash in cleanForSlug
tyxla 3f496c6
url: Remove _.every() from tests
tyxla 8b6e39a
url: Remove unnecessary extra trim
tyxla f6a8d56
Handle multiple leading or trailing dashes
tyxla f2f238a
Add a test to cover multiple leading and trailing dashes
tyxla 8832905
Add comments in cleanForSlug for comprehensibility
tyxla 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
url: Use removeAccents instead of lodash in cleanForSlug
- Loading branch information
commit 16afd375fd298c63d7b2d8288bba535a0db76b46
There are no files selected for viewing
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Would this work too, @tyxla ?
Found it on StackOverflow – perhaps we could do without the
remove-accentsdependency entirely? I saw it was based on a characters map so perhapsstr.normalizewould give us an even better coverage for free?Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for asking @adamziel, it's actually a great question!
I'd be happy to go with that, it's always ideal to not rely on another package. The thing is, that solution works for most of the characters, but from what I've seen, it doesn't cover them all, or at least, doesn't cover as many as the package I've used covers.
Try this in your browser console - I've built it from the character map of the package:
and you'll get:
where while the result is satisfactory, you will notice that there are quite a few that actually remain unchanged.
For the library above, we also used the corresponding WP function originally when compiling the character map, so this also gets us closer to a parity with the WordPress backend - a nice side benefit IMHO.
What do you think?
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.
Nice test!
Alright, let's go with the package 👍