Clean URL search params

Closes #316
This commit is contained in:
Max Isom 2021-09-14 09:42:45 -04:00
parent 4bce011b0c
commit fcbff53a7a
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
3 changed files with 21 additions and 3 deletions

View file

@ -34,7 +34,16 @@ export default class {
async youtubeVideo(url: string): Promise<QueuedSong|null> {
try {
const videoDetails = await this.youtube.videos.get(url);
// Clean URL
const u = new URL(url);
for (const [name] of u.searchParams) {
if (name !== 'v') {
u.searchParams.delete(name);
}
}
const videoDetails = await this.youtube.videos.get(u.toString());
return {
title: videoDetails.snippet.title,