Skip to content

Commit

Permalink
Add fix for shortened youtu.be links in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
omarroth committed Sep 6, 2018
1 parent 446d856 commit cf63c82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/invidious.cr
Expand Up @@ -1816,6 +1816,7 @@ get "/api/v1/comments/:id" do |env|
body = html.body
session_token = body.match(/'XSRF_TOKEN': "(?<session_token>[A-Za-z0-9\_\-\=]+)"/).not_nil!["session_token"]
ctoken = body.match(/'COMMENTS_TOKEN': "(?<ctoken>[^"]+)"/)

if !ctoken
env.response.content_type = "application/json"

Expand Down Expand Up @@ -1909,7 +1910,10 @@ get "/api/v1/comments/:id" do |env|
url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
if url
url = URI.parse(url)

if url.path == "/redirect"
url = HTTP::Params.parse(url.query.not_nil!)["q"]
end
else
url = run["navigationEndpoint"]["commandMetadata"]?.try &.["webCommandMetadata"]["url"].as_s
end
Expand Down

0 comments on commit cf63c82

Please sign in to comment.