ruby - Rails check if URL is already encoded -
i using uri.encode encode url's in rail's application. these url's can encoded , not want encode them again. can see 1 solution here: how find out if string has been url encoded?
however, wondering there api available in ruby doing ?
also suggested in https://stackoverflow.com/a/2295286/1475737 decoding string , checking length original correct solution ?
appreciate suggestions!
the 'uri'
module has regular expression holding list of characters should escaped uri encoding:
require 'uri' uri::regexp::unsafe => /[^-_.!~*'()a-za-z\d;\/?:@&=+$,\[\]]/n
so 1 solution test whether given string matches regexp , encode if does.
Comments
Post a Comment