api/src/services/url: support for longer Loom URL variant containing content ID #832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
aliasURL
inurl.js
to 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 supposedid
containing 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 test
as 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.