Joined December 2012
·

Michał Kowalkowski

CTO at Stktk
·
Warsaw
·
·
·

Posted to Make string url ready over 1 year ago

@xero You are right - it would be easier. I can only say to that, what I said to "dimasmagadan" in my post before.
If you do not care how the url will look like, then functions you proposed are valid and much easier solution.

Posted to Make string url ready over 1 year ago

@dimasmagadan You raise a valid point. Functions you mention are a good way to encode string to be used in url.
Why I use my method is because I like more control over how the url will look like.
I think "this-is-some-text-with-tab-new-line-and-lot-of-spaces" is a little more elegant than "+This+Is+Some%2FText+with%09tab%0Anew+line+and+lot+of+++++++spaces%0A".
Also by using regex you can easily customize my method and specify how you want it to handle special characters like ? & or dots.

Achievements
276 Karma
13,568 Total ProTip Views