Skip to content
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

url_title not detecting some special characteres #3038

Closed
mmacagnan opened this issue May 27, 2020 · 7 comments
Closed

url_title not detecting some special characteres #3038

mmacagnan opened this issue May 27, 2020 · 7 comments

Comments

@mmacagnan
Copy link

Hey, it's so nice to participate in an improvement for this spectacular framework.
Yesterday I commit a change to a client system. When he try to create a resource all seems to be fine, but i used the url_title to slugify the title to url and save it to the database.

The problem is that did not detected some special characteres like ç,~,`

image

image

@natanfelles
Copy link
Contributor

Try like this

function url_segment(string $text) : string
{
	$text = url_title($text, '-', true);
	helper('text');
	$text = convert_accented_characters($text);
	return $text;
}

@lonnieezell
Copy link
Member

@natanfelles is absolutely correct. For a deeper explanation the HTTP spec (RFC-3986) does not allow characters outside of the US-ASCII as part of a URI, unless it's been encoded.

That being said, I'm wondering if we should incorporate that into the url_title() helper method itself, or just make a note of it in the docs. I'm leaning toward docs because otherwise it might be a surprise to developers.

@natanfelles @MGatner @michalsn what do you guys think?

@natanfelles
Copy link
Contributor

The convert_accented_characters should be incorporated.

@mmacagnan
Copy link
Author

Thank you.
It would be nice if the functionality of convert_accented_characters is implemented in url_title

@michalsn
Copy link
Member

michalsn commented Jun 8, 2020

I remember many discussions about this one in the past. Personally, I would love to see url_title() handling accented characters under the hood, but at this point, it's too late for that since developers may rely on produced results heavily.

Another option would be to introduce yet another parameter to url_title() function, but idk if I would like to see this.

If I gonna need this functionality I will probably write a simple helper for that, just like I always did in CI3.

@lonnieezell
Copy link
Member

I think a good solution would be to create a new helper function in the url_helper: mb_url_title.
Thoughts? Anyone want to submit a PR?

@michalsn
Copy link
Member

Resolved via #3086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants