added logic to prevent duplicate url's from being entered, it just
fetches the url and load it instead
This commit is contained in:
@@ -19,8 +19,10 @@ class App < Roda
|
||||
|
||||
r.post "create" do
|
||||
url = r.params['url']
|
||||
code = SecureRandom.urlsafe_base64 4
|
||||
if nil == links.filter(:url => url).first
|
||||
code = SecureRandom.urlsafe_base64 5
|
||||
links.insert(url: url, code: code)
|
||||
end
|
||||
@new_link = 'http://' + request.env['HTTP_HOST'] + '/' + links.filter(:url => url).first[:code]
|
||||
view :create
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user