Skip to content

Commit

Permalink
Improved the work of constructing links to private videos for vimeo e…
Browse files Browse the repository at this point in the history
…mbed
  • Loading branch information
ilyhalight committed Sep 25, 2024
1 parent da6546b commit cd0bb6d
Show file tree
Hide file tree
Showing 280 changed files with 385 additions and 362 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.3.1

- Improved the work of constructing links to private videos for vimeo embed

# 1.3.0

> [!CAUTION]
Expand Down
2 changes: 1 addition & 1 deletion dist/client.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/helpers/vimeo.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions dist/helpers/vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ export default class VimeoHelper extends BaseHelper {
const baseUrl = new URL(cdnUrl);
const pathLength = Array.from(data.base_url.matchAll(/\.\.\//g)).length + 1;
const pathFragments = baseUrl.pathname.split("/");
baseUrl.pathname = pathFragments
.slice(0, pathFragments.length - pathLength)
.join("/");
let extraPath = data.base_url.replaceAll("../", "");
extraPath =
extraPath && !extraPath.startsWith("/") ? `/${extraPath}` : extraPath;
baseUrl.pathname =
pathFragments.slice(0, pathFragments.length - pathLength).join("/") +
extraPath;
if (!baseUrl.pathname.endsWith("/")) {
baseUrl.pathname += "/";
}
const videoData = data.audio.find((v) => v.mime_type === "audio/mp4" && v.format === "dash");
if (!videoData) {
throw new VideoHelperError("Failed to find video data");
Expand All @@ -72,9 +78,9 @@ export default class VimeoHelper extends BaseHelper {
throw new VideoHelperError("Failed to find first segment url");
}
const [videoName, videoParams] = segmentUrl.split("?", 2);
baseUrl.pathname += `/${videoData.base_url}${videoName}`;
const params = new URLSearchParams(videoParams);
params.delete("range");
baseUrl.pathname += `${videoData.base_url}${videoName}`;
baseUrl.href = baseUrl.href.split("?")[0] + "?" + params.toString();
return baseUrl.href;
}
Expand Down
Loading

0 comments on commit cd0bb6d

Please sign in to comment.