-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
[5.x] Fix hyphens in JS slugs #10541
Conversation
This would make dashes never work. It's perfectly fine for slugs in general to have dashes. Usually that's only what should be used. What's happening in the referenced issue is that the validation wants a But we are only telling it to use Line 494 in a074cb4
The JS still allows you to manually type dashes. They're valid in PHP too: Str::snake('foo bar-baz'); // foo_bar-baz What we probably need is a new method that enforces changing dashes to underscores. Maybe something like: Statamic.$slug.separatedBy('_').withReplacements({'-': '_'}).create(string); replacements:
'-': '_'
The |
Good suggestion! I've reverted my previous fix and instead went ahead with the |
# Conflicts: # resources/js/components/slugs/Slug.js
let custom = charmap[this.#language] ?? {}; | ||
custom["'"] = ""; // Remove apostrophes in all languages | ||
custom["’"] = ""; // Remove smart single quotes | ||
custom[" - "] = " "; // Prevent `Block - Hero` turning into `block_-_hero` |
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.
Why'd this need to be removed?
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 think I was thinking it might not be needed after these changes...
However, on second thought, I'll add it back since not all slug/handle fields specify replacements
. 👍
…n using non-dash separator. it matches php.
I realized (after you made all my requested changes 😬) that in PHP's So, I reverted the Everything you did was great and worked well, but I don't think we need it. Thank you and sorry! |
This pull request fixes an issue where hyphens weren't being handled correctly in JS slugs.
Fixes #10533.