mirror of
https://github.com/imputnet/cobalt.git
synced 2026-05-22 14:24:23 -05:00
[PR #832] [MERGED] api/url: extract loom video id from longer links #13536
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/imputnet/cobalt/pull/832
Author: @styxnanda
Created: 10/10/2024
Status: ✅ Merged
Merged: 2/11/2025
Merged by: @wukko
Base:
main← Head:loom-fix-branch📝 Commits (2)
ab52297api/src/services/url: support for longer Loom URL variant containing content ID0c1f6b5api/processing: reformat📊 Changes
1 file changed (+8 additions, -0 deletions)
View changed files
📝
api/src/processing/url.js(+8 -0)📄 Description
Background
This is in response to #799.
It's not really a bug, but the original code intended the ID for Loom videos to be at most 32 characters. For example,
https://www.loom.com/share/4a2a8baf124c4390954dcbb46a58cfd7.However, apparently Loom has a longer URL variant that has the title encoded as well such as
https://www.loom.com/share/Unlocking-Incredible-Organizational-Velocity-with-Async-Video-4a2a8baf124c4390954dcbb46a58cfd7.However, I did notice that in this longer variant URL form, the URL actually contains the ID right at the end of the path. For example in
https://www.loom.com/share/Unlocking-Incredible-Organizational-Velocity-with-Async-Video-4a2a8baf124c4390954dcbb46a58cfd7, the ID of the video is4a2a8baf124c4390954dcbb46a58cfd7.Solving Attempt
So, what I did is pretty much utilize the function
aliasURLinurl.jsto provide support for this URL variant. Then, I changed the URL pathname to the correct format so the patternMatch is the exact ID to be later on tested by the tester pattern by extracting the last 32 characters from the supposedidcontaining more than 32 characters. Here's the code mentioned.Test Result
I've done a manual test using Yaak and it succeeds in the supposedly unyielding URLs.

I've run
npm run testas well and met some failures in reddit, streamable, and vimeo test cases but this is because those sites are banned in my country. It shouldn't affect those at all though.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.