jbroadway / urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Underscores as spaces

tobiassjosten opened this issue · comments

I just had URLify take the title _Summer and return the slug _summer, when I was actually expecting just summer. Maybe this is just me though?

Going forward I have my wrapper replace all occurrences of underscores with spaces. This matches at least my own internal logic much better but I wanted to throw it out there and see if maybe someone else also liked this behavior. Then I could roll a PR for it.

Apparently this is because PCRE considers underscores to be valid word characters matched by \w, which is kind of odd. I guess \w may also match accent characters depending on the locale, but since we've stripped them out before that line (line 206), it doesn't cause an issue with anything but underscores.

But I agree, underscores should be converted dashes in the final output.