diff --git a/src/routes/[...dir]/[file=pdf]/+page.svelte b/src/routes/[...dir]/[file=pdf]/+page.svelte index a80e652..04eed75 100644 --- a/src/routes/[...dir]/[file=pdf]/+page.svelte +++ b/src/routes/[...dir]/[file=pdf]/+page.svelte @@ -11,11 +11,27 @@ iframe.contentWindow?.focus(); // Focus the iframe }); - $: title = getTitle(data.url); - function getTitle(url: string) { + function genTitle(url: string) { const part = url.split('/'); return part[part.length - 1].split('?')[0]; } + $: title = genTitle(data.url); + + function genIframeUrl(baseUrl: string) { + const params = $page.url.searchParams; + + if (params.has('page')) { + const pageParam = params.get('page'); + // if page is a number, append it to the url (security) + const pageParamNumber = Number(pageParam); + if (!isNaN(pageParamNumber)) { + baseUrl += `#page=${pageParamNumber}`; + } + } + + return baseUrl; + } + $: iframeUrl = genIframeUrl(data.url); @@ -25,7 +41,7 @@ - +