namecase
namecase copied to clipboard
support for html encoded strings
Currently if I pass & through, namecase changes it to &Amp; which breaks decoding. Please add an ignore for html encoded entities.
<
, >
, &
, '
and "
Here is what I'm having to do currently to get around the problem:
$adjusted_name = str_name_case($input);
// Use preg_replace_callback to match HTML entities and convert them to lowercase.
$adjusted_name = preg_replace_callback('/&[a-zA-Z0-9#]+;/', function($matches) {
return strtolower($matches[0]);
}, $adjusted_name);
return $adjusted_name;
I'm sorry for the late fix! @objecttothis but is it possible to ask you to verify the fixed version:
composer require tamtamchik/namecase:3.1.0-beta.0
Thank you for this fix. I work on the project which uses this library on Mondays and Tuesdays so I'll make a note to test it on Monday. We are at end of day Tuesday here.
I'm sorry for the late fix! @objecttothis but is it possible to ask you to verify the fixed version:
composer require tamtamchik/namecase:3.1.0-beta.0
Just tested 3.1.0-beta.0 and the following
gets replaced with
Which is what I would expect, but this
gets replaced with
I didn't get this behavior every time, though it was unclear to me exactly which circumstances it was giving the correct output
I think my example isn't really clear.
When I submit
the first time I got
and that is what I expect to get back. However when I resubmit
I get
which is not expected. The difference between the two is that the first requires capitalization of joe
. I was able to repeat the result, so it's something to do with the way it's handling Joe &
differently than joe &
Thank you for the feedback, @objecttothis; that is why I didn't publish it as a new release. I'll debug and fix the issue ASAP.
@objecttothis, try this one; sorry for being late, I was trying different approaches, but the one you use looks like the most reliable.
composer require tamtamchik/namecase:3.1.0-beta.1
Sounds good. I'm out of the office until the 16th but I'll test it then if it's still needed.