Permalink
Browse files

Merge pull request #22 from labcoder/master

Fixed URI parse error on missing uri scheme from user input
  • Loading branch information...
2 parents 5b91bd8 + 89f44df commit da59099970c65e9f068d6fe46ef82138235bedff Kevin Burke committed Sep 7, 2013
Showing with 14 additions and 0 deletions.
  1. +8 −0 README.md
  2. +6 −0 app/app.rb
View
@@ -38,6 +38,8 @@ Run Locally
### Setting up Postgres
+Make sure you have the user `postgres` created
+
In `psql` run:
# CREATE DATABASE hurls;
@@ -46,6 +48,12 @@ In `psql` run:
# create table hurls (id character(40), content bytea);
# create table users (id character(40), content bytea);
+Make sure to have the proper permissions:
+ # Assign owner to postgres
+ # ALTER TABLE views OWNER TO postgres;
+ # ALTER TABLE hurls OWNER TO postgres;
+ # ALTER TABLE users OWNER TO postgres;
+
Now visit <http://localhost:9393>
Run in Heroku
View
@@ -192,6 +192,12 @@ def invalid_url?(url)
valid_schemes = ['http', 'https']
begin
uri = URI.parse(url)
+ unless uri.path.nil?
+ if uri.host.nil? and uri.scheme.nil?
+ uri.host = uri.path
+ uri.scheme = 'http'
+ end
+ end
raise URI::InvalidURIError if uri.host == 'hurl.it'
raise URI::InvalidURIError if !valid_schemes.include? uri.scheme
false

0 comments on commit da59099

Please sign in to comment.