refactor: use url.href instead of url.toString()

This commit is contained in:
WebStreamr 2025-05-16 22:14:41 +02:00
parent 16b01a57fd
commit b790cc7954
No known key found for this signature in database
4 changed files with 5 additions and 5 deletions

View file

@ -19,7 +19,7 @@ export class Dropload implements Extractor {
readonly supports = (url: URL): boolean => null !== url.host.match(/dropload/);
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
const normalizedUrl = url.toString().replace('/e/', '').replace('/embed-', '/');
const normalizedUrl = url.href.replace('/e/', '').replace('/embed-', '/');
const html = await this.fetcher.text(ctx, new URL(normalizedUrl));
const heightMatch = html.match(/\d{3,}x(\d{3,}),/) as string[];

View file

@ -19,12 +19,12 @@ export class Mixdrop implements Extractor {
readonly supports = (url: URL): boolean => null !== url.host.match(/mixdrop/);
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
const normalizedFullUrl = url.toString().replace('/e/', '/f/');
const normalizedFullUrl = url.href.replace('/e/', '/f/');
const fullHtml = await this.fetcher.text(ctx, new URL(normalizedFullUrl));
const sizeMatch = fullHtml.match(/([\d.]+ ?[GM]B)/) as string[];
const normalizedEmbedUrl = url.toString().replace('/f/', '/e/');
const normalizedEmbedUrl = url.href.replace('/f/', '/e/');
const embedHtml = await this.fetcher.text(ctx, new URL(normalizedEmbedUrl));
return {

View file

@ -19,7 +19,7 @@ export class SuperVideo implements Extractor {
readonly supports = (url: URL): boolean => null !== url.host.match(/supervideo/);
readonly extract = async (ctx: Context, url: URL, countryCode: string) => {
const normalizedUrl = url.toString().replace('/e/', '/').replace('/embed-', '/');
const normalizedUrl = url.href.replace('/e/', '/').replace('/embed-', '/');
const html = await this.fetcher.text(ctx, new URL(normalizedUrl));
const heightAndSizeMatch = html.match(/\d{3,}x(\d{3,}), ([\d.]+ ?[GM]B)/) as string[];

View file

@ -78,7 +78,7 @@ export class StreamResolver {
}
return {
url: urlResult.url.toString(),
url: urlResult.url.href,
name,
title,
behaviorHints: {