Skip to content

Commit

Permalink
fixed absolute url in the vtt file (#610)
Browse files Browse the repository at this point in the history
fixed the type file path
  • Loading branch information
vaseala authored Aug 31, 2023
1 parent 1fe653e commit cafff9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/artplayer-plugin-vtt-thumbnail/src/getVttArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export default async function getVttArray(vttUrl = '') {
const start = Math.floor(t2d(timeMatch[1]));
const end = Math.floor(t2d(timeMatch[2]));

const urlArr = vttUrl.split('/');
urlArr.pop();
urlArr.push(textMatch[1]);
const url = urlArr.join('/');
let url = textMatch[1];
const isAbsoluteUrl = /^\/|((https?|ftp|file):\/\/)/i.test(url);
if (!isAbsoluteUrl) {
const urlArr = vttUrl.split('/');
urlArr.pop();
urlArr.push(url);
url = urlArr.join('/');
}

const result = { start, end, url };

Expand Down

1 comment on commit cafff9b

@vercel
Copy link

@vercel vercel bot commented on cafff9b Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.