Joined December 2012
·
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
14,539 Total ProTip Views

Honey Badger
Have at least one original Node.js-specific repo

Lemmings 100
Write something great enough to have at least 100 watchers of the project

Forked
Have a project valued enough to be forked by someone else

Charity
Fork and commit to someone's open source project in need

Cub
Have at least one original jQuery or Prototype open source repo
@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.