diff --git a/src/lib/match.ts b/src/lib/match.ts index edf6793..96f73a1 100644 --- a/src/lib/match.ts +++ b/src/lib/match.ts @@ -1,5 +1,6 @@ -import { unpack } from './utils'; +import { unpack } from './util/userspace'; import { Hosters, Redirect, TmpHost } from './settings'; +import {lastPathSegment} from "~/lib/util/extract"; export interface Match { name: string; @@ -113,10 +114,9 @@ export const LoadX: Match = { regex: [/./gm], match: async () => { - const postMatch = window.location.href.match(/(?<=\/video\/)\S*(\/.*)?/)!; - + const hash = encodeURIComponent(lastPathSegment(window.location.href)); const response = await fetch( - `https://${window.location.host}/player/index.php?data=${encodeURIComponent(postMatch[0])}&do=getVideo`, + `https://${window.location.host}/player/index.php?data=${hash}&do=getVideo`, { method: 'POST', headers: { @@ -140,11 +140,9 @@ export const Luluvdo: Match = { regex: [/./gm], match: async () => { - const postMatch = window.location.href.match(/(?<=\/embed\/)\S*(\/.*)?/)!; - const requestBody = new FormData(); requestBody.set('op', 'embed'); - requestBody.set('file_code', postMatch[0]); + requestBody.set('file_code', lastPathSegment(window.location.href)); const response = await fetch(`https://${window.location.host}/dl`, { method: 'POST', body: requestBody, diff --git a/src/lib/util/extract.ts b/src/lib/util/extract.ts new file mode 100644 index 0000000..d1f2990 --- /dev/null +++ b/src/lib/util/extract.ts @@ -0,0 +1,3 @@ +export function lastPathSegment(path: string): string { + return path.substring(path.lastIndexOf('/')); +} diff --git a/src/lib/utils.ts b/src/lib/util/userspace.ts similarity index 100% rename from src/lib/utils.ts rename to src/lib/util/userspace.ts