FIX dev branch error with loading youtube links that have no params (#570)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description
This is a quick and dirty fix to youtube links not having parameters

**This fixes a branch issue**

#### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
I have asked God for the solution
This commit is contained in:
Rose authored and GitHub committed 2026-03-28 15:26:10 +00:00
commit 5433f293c1
1 file changed
+5 -3
@@ -166,7 +166,7 @@ function parseYoutubeLink(url: string): YoutubeLink | null {
if (url.includes('youtu.be')) {
const split = path.split('?');
[videoId] = split;
params = split[1].split('&');
params = split[1]?.split('&');
} else {
params = path.split('?')[1].split('&');
videoId = params.find((s) => s.startsWith('v='), params)?.split('v=')[1];
@@ -175,8 +175,10 @@ function parseYoutubeLink(url: string): YoutubeLink | null {
if (!videoId) return null;
// playlist is not used for the embed, it can be appended as is
const playlist = params.find((s) => s.startsWith('list='), params);
const timestamp = params.find((s) => s.startsWith('t='), params)?.split('t=')[1];
const playlist = params ? params.find((s) => s.startsWith('list='), params) : undefined;
const timestamp = params
? params.find((s) => s.startsWith('t='), params)?.split('t=')[1]
: undefined;
return {
videoId,