]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix 404 when having ;threadId param
authorChocobozzz <me@florianbigard.com>
Thu, 2 Mar 2023 09:35:59 +0000 (10:35 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 2 Mar 2023 09:35:59 +0000 (10:35 +0100)
server/controllers/client.ts
server/tests/client.ts

index f9514d988f9be01d262aaa6837251351a3695814..a85c1072019d8ab01e5f519506f652500c544011 100644 (file)
@@ -138,7 +138,14 @@ async function generateEmbedHtmlPage (req: express.Request, res: express.Respons
 }
 
 async function generateWatchHtmlPage (req: express.Request, res: express.Response) {
-  const html = await ClientHtml.getWatchHTMLPage(req.params.id + '', req, res)
+  // Thread link is '/w/:videoId;threadId=:threadId'
+  // So to get the videoId we need to remove the last part
+  let videoId = req.params.id + ''
+
+  const threadIdIndex = videoId.indexOf(';threadId')
+  if (threadIdIndex !== -1) videoId = videoId.substring(0, threadIdIndex)
+
+  const html = await ClientHtml.getWatchHTMLPage(videoId, req, res)
 
   return sendHTML(html, res, true)
 }
index e0dae2b5e320894c8b4120b66641d6528fc46939..9a20c2a10361b29b52264b423d30e7993df04c57 100644 (file)
@@ -225,6 +225,14 @@ describe('Test a client controllers', function () {
       }
     })
 
+    it('Should have valid Open Graph tags on the watch page with thread id Angular param', async function () {
+      for (const path of watchVideoBasePaths) {
+        for (const id of videoIds) {
+          await watchVideoPageTest(path + id + ';threadId=1')
+        }
+      }
+    })
+
     it('Should have valid Open Graph tags on the watch playlist page', async function () {
       for (const path of watchPlaylistBasePaths) {
         for (const id of playlistIds) {