added logic to prevent duplicate url's from being entered, it just
fetches the url and load it insteadpull/6/head
parent
935b0c5a9f
commit
47f8741592
6
app.rb
6
app.rb
|
|
@ -19,8 +19,10 @@ class App < Roda
|
||||||
|
|
||||||
r.post "create" do
|
r.post "create" do
|
||||||
url = r.params['url']
|
url = r.params['url']
|
||||||
code = SecureRandom.urlsafe_base64 4
|
if nil == links.filter(:url => url).first
|
||||||
links.insert(url: url, code: code)
|
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]
|
@new_link = 'http://' + request.env['HTTP_HOST'] + '/' + links.filter(:url => url).first[:code]
|
||||||
view :create
|
view :create
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue