summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-10-06 22:19:36 -0500
committerOmar Roth <omarroth@hotmail.com>2018-10-06 22:19:36 -0500
commit6f9056fd8473cf227b1ab572c3d75cbbb79c094e (patch)
tree40f686aec49837fed4fcdcfba79ba07e8b9c6e9c
parent3733fe827268887733ea99d8740c78547e176343 (diff)
downloadinvidious-6f9056fd8473cf227b1ab572c3d75cbbb79c094e.tar.gz
invidious-6f9056fd8473cf227b1ab572c3d75cbbb79c094e.tar.bz2
invidious-6f9056fd8473cf227b1ab572c3d75cbbb79c094e.zip
Add extra handling for shortened video URLs
-rw-r--r--src/invidious.cr18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 5526b089..e6130f34 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -3437,6 +3437,24 @@ get "/vi/:id/:name" do |env|
end
error 404 do |env|
+ if md = env.request.path.match(/^\/(?<id>[a-zA-Z0-9_-]{11})/)
+ id = md["id"]
+
+ params = [] of String
+ env.params.query.each do |k, v|
+ params << "#{k}=#{v}"
+ end
+ params = params.join("&")
+
+ url = "/watch?v=#{id}"
+ if !params.empty?
+ url += "&#{params}"
+ end
+
+ env.response.headers["Location"] = url
+ halt env, status_code: 302
+ end
+
error_message = "404 Page not found"
templated "error"
end