Last Updated: May 31, 2021
·
1.036K
· ichiriac

Generic way to sanitize url by stripping any special char

2 Responses
Add your response

OK, great. Now try to transform this 'sanitized' URL back?

Some religious rules disallow you use urlencode()?

By the way, do you happen to know this guy?)
https://coderwall.com/p/a-viza

over 1 year ago ·

@dimasmagadan Hi,

The short answer for not using urlencode is yes, I know about it and I don't want to use it.

For more explanations, the reason is that I need to build a unique URLs index and I don't care about retrieving the original title from the URL, but with these function I can filter all url variations and be sure that urls are not the same :

  • case sensitive
  • ignore any accents
  • removing tags
  • remove special chars
  • (optionnaly) only alpha numerics
over 1 year ago ·