https://github.com/laravel/framework/blob/5.6/src/Illuminate/Support/Str.php#L410
If you'd like to make a pull request with some additions...it's a relatively small function.
Curious if this is by design or if it's a bug.
I'm using the helper function str_slug (Support\Str.php) to create URL-friendly slugs when a page or post is created similar to the way Wordpress does. I noticed that any time an ampersand (&) or hash tag (#) is included, str_slug strips everything in the string after that character.
Example:
Input: Nuts & Bolts Returned: String: nuts
Input: Nuts # bolts Returned: nuts
I would expect the function to simply remove the "&" or "#" and return the string "nuts-bolts" but instead it seems to strip everything after the ampersand or hash tag. I've tried this with much longer strings and get the same result.
Anyone else have this issue?
It's not the same with other characters, as it replaces the "@" symbol with the word "at" and simply strips out other characters and leaves the remaining string intact.
I haven't tested all possible special characters, but these two are the ones that I've personally come across that seem to invoke this behavior.
Not sure if this is by design or if there is something else causing it.
Kind of annoying, though.
May have to rethink using this helper for slug creation and create a custom one.
It's probably meant to remove/avoid query strings and anchors in the URL, e.g.
Please or to participate in this conversation.