mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add extra handling for year format
This commit is contained in:
parent
9d6cdc3032
commit
5a6b36ecce
2 changed files with 14 additions and 5 deletions
|
@ -336,19 +336,23 @@ end
|
||||||
# Search
|
# Search
|
||||||
|
|
||||||
get "/results" do |env|
|
get "/results" do |env|
|
||||||
search_query = env.params.query["search_query"]?
|
query = env.params.query["search_query"]?
|
||||||
|
query ||= env.params.query["q"]?
|
||||||
|
query ||= ""
|
||||||
|
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
page ||= 1
|
page ||= 1
|
||||||
|
|
||||||
if search_query
|
if query
|
||||||
env.redirect "/search?q=#{URI.escape(search_query)}&page=#{page}"
|
env.redirect "/search?q=#{URI.escape(query)}&page=#{page}"
|
||||||
else
|
else
|
||||||
env.redirect "/"
|
env.redirect "/"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/search" do |env|
|
get "/search" do |env|
|
||||||
query = env.params.query["q"]?
|
query = env.params.query["search_query"]?
|
||||||
|
query ||= env.params.query["q"]?
|
||||||
query ||= ""
|
query ||= ""
|
||||||
|
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
|
|
|
@ -63,7 +63,12 @@ def decode_time(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode_date(string : String)
|
def decode_date(string : String)
|
||||||
# Time matches format "20 hours ago", "40 minutes ago"...
|
# String matches 'YYYY'
|
||||||
|
if string.match(/\d{4}/)
|
||||||
|
return Time.new(string.to_i, 1, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
# String matches format "20 hours ago", "40 minutes ago"...
|
||||||
date = string.split(" ")[-3, 3]
|
date = string.split(" ")[-3, 3]
|
||||||
delta = date[0].to_i
|
delta = date[0].to_i
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue