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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -