Skip to content

Commit

Permalink
fix: add ts to d_url of iframe preview (close AlistGo/alist#5613)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Dec 3, 2023
1 parent 1786327 commit 059e45d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pages/home/previews/iframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const IframePreview = (props: { scheme: string }) => {
raw_url: objStore.raw_url,
name: objStore.obj.name,
d_url: currentObjLink(true),
ts: true,
})
})
return (
Expand Down
7 changes: 7 additions & 0 deletions src/utils/str.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ export type ConvertURLArgs = {
raw_url: string
name: string
d_url: string
ts?: boolean
}

export const convertURL = (scheme: string, args: ConvertURLArgs) => {
let ans = scheme
ans = ans.replace("$name", args.name)
if (args.ts) {
const d = new URL(args.d_url)
const ts = Date.now()
d.searchParams.set("alist_ts", ts.toString())
args.d_url = d.toString()
}
ans = ans.replace(/\$[eb_]*url/, (old) => {
const op = old.match(/e|b/)
let u = args.raw_url
Expand Down

0 comments on commit 059e45d

Please sign in to comment.