Skip to content

Instantly share code, notes, and snippets.

@3cp
Created May 8, 2013 05:04
Show Gist options
  • Save 3cp/5538314 to your computer and use it in GitHub Desktop.
Save 3cp/5538314 to your computer and use it in GitHub Desktop.
Ruby equivalent code of Javascript encodeURIComponent(...)
require 'uri'
# same result as Javascript encodeURIComponent(...)
puts URI.escape(ARGV[0], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment