mirror of
				https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
				synced 2024-08-15 00:53:38 +00:00 
			
		
		
		
	Fix /c/ redirect
This commit is contained in:
		
							parent
							
								
									eb8b0f72cc
								
							
						
					
					
						commit
						b37f51bd7f
					
				
					 1 changed files with 4 additions and 6 deletions
				
			
		| 
						 | 
					@ -3467,14 +3467,12 @@ get "/c/:user" do |env|
 | 
				
			||||||
  user = env.params.url["user"]
 | 
					  user = env.params.url["user"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  response = YT_POOL.client &.get("/c/#{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")]))
 | 
					  ucid = html.xpath_node(%q(//link[@rel="canonical"])).try &.["href"].split("/")[-1]
 | 
				
			||||||
  if !anchor
 | 
					  next env.redirect "/" if !ucid
 | 
				
			||||||
    next env.redirect "/"
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  env.redirect anchor["href"]
 | 
					  env.redirect "/channel/#{ucid}"
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Legacy endpoint for /user/:username
 | 
					# Legacy endpoint for /user/:username
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue