main_app/doc/shorten/main.rb
# Determine if a URL is valid.  We run it through 
Determine if a URL is valid.  We run it through
Determine if a URL is valid . We run it through
def valid_url?(url)
		if url.include? "%3A"
			url = URI.unescape(url)
		end
		retval = true
		begin
			uri = URI.parse(URI.escape(url))
			if uri.class != URI::HTTP
				retval = false
			end
			host = (URI.split(url))[2]
			if host =~ /^(localhost|192\.168\.\d{1,3}\.\d{1,3}|127\.0\.0\.1|172\.((1[6-9])|(2[0-9])|(3[0-1])).\d{1,3}\.\d{1,3}|10.\d{1,3}\.\d{1,3}.\d{1,3})/
				retval = false
			end
		rescue URI::InvalidURIError
				retval = false
		end
		retval
	end
def valid_url? ( url ) if url . include? "%3A" url = URI . unescape ( url ) end retval = true begin uri = URI . parse ( URI . escape ( url ) ) if uri . class != URI :: HTTP retval = false end host = ( URI . split ( url ) ) [ 2 ] if host =~ / ^(localhost|192 \. 168 \. \d {1,3} \. \d {1,3}|127 \. 0 \. 0 \. 1|172 \. ((1[6-9])|(2[0-9])|(3[0-1])). \d {1,3} \. \d {1,3}|10. \d {1,3} \. \d {1,3}. \d {1,3}) / retval = false end rescue URI :: InvalidURIError retval = false end retval end
Determine if a URL is valid.
Determine if a URL is valid .
url
<not_specific>