diff options
| author | Omar Roth <omarroth@hotmail.com> | 2019-04-17 14:46:00 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2019-04-17 14:46:00 -0500 |
| commit | 25359e53201b06f76c6eed1e355f9a9fa63543ed (patch) | |
| tree | f71ea06a51305598e7d92441e8db0a2012ea6dc8 /src | |
| parent | b6fff53b21e416ddfa9b010710786d5e23890271 (diff) | |
| download | invidious-25359e53201b06f76c6eed1e355f9a9fa63543ed.tar.gz invidious-25359e53201b06f76c6eed1e355f9a9fa63543ed.tar.bz2 invidious-25359e53201b06f76c6eed1e355f9a9fa63543ed.zip | |
Fix typo in 404 handler
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 3abd9c51..299ef8bc 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -4678,10 +4678,11 @@ end error 404 do |env| if md = env.request.path.match(/^\/(?<id>([a-zA-Z0-9_-]{11})|(\w+))$/) - id = md["id"] + item = md["id"] + # Check if item is branding URL e.g. https://youtube.com/gaming client = make_client(YT_URL) - response = client.get("/#{id}") + response = client.get("/#{item}") if response.status_code == 301 response = client.get(response.headers["Location"]) @@ -4701,13 +4702,14 @@ error 404 do |env| end params = params.join("&") - url = "/watch?v=#{id}" + url = "/watch?v=#{item}" if !params.empty? url += "&#{params}" end - client = make_client(YT_URL) - if client.head("/#{id}").status_code == 404 + # Check if item is video ID + client = make_client(URI.parse("https://youtu.be")) + if client.head("/#{item}").status_code != 404 env.response.headers["Location"] = url halt env, status_code: 302 end |
