diff options
| author | Omar Roth <omarroth@protonmail.com> | 2020-04-04 15:31:24 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2020-04-04 15:31:24 -0500 |
| commit | b37f51bd7f5c8bc921a72ab3e549e878746e98de (patch) | |
| tree | 09bd1819710535cfe909354ec63994c8ca69454c | |
| parent | eb8b0f72cc91c8e1c3ae9a36cc397b2fea8c808c (diff) | |
| download | invidious-b37f51bd7f5c8bc921a72ab3e549e878746e98de.tar.gz invidious-b37f51bd7f5c8bc921a72ab3e549e878746e98de.tar.bz2 invidious-b37f51bd7f5c8bc921a72ab3e549e878746e98de.zip | |
Fix /c/ redirect
| -rw-r--r-- | src/invidious.cr | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 73546d7d..3ceac127 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -3467,14 +3467,12 @@ get "/c/:user" do |env| user = env.params.url["user"] response = YT_POOL.client &.get("/c/#{user}") - document = XML.parse_html(response.body) + html = XML.parse_html(response.body) - anchor = document.xpath_node(%q(//a[contains(@class,"branded-page-header-title-link")])) - if !anchor - next env.redirect "/" - end + ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1] + next env.redirect "/" if !ucid - env.redirect anchor["href"] + env.redirect "/channel/#{ucid}" end # Legacy endpoint for /user/:username |
