diff --git a/src/routes/Browse.svelte b/src/routes/Browse.svelte index 0b6de178b3d246b9554b901b34bca6f757437700..1427fefd3605ab716acc2040b77008a549fe5bc0 100644 --- a/src/routes/Browse.svelte +++ b/src/routes/Browse.svelte @@ -1,7 +1,7 @@ <script> import { onMount } from "svelte"; import { paths } from "@/static/js/paths"; - import { fetchAPI } from "@/static/js/helper"; + import { fetchAPI, getQueryValue } from "@/static/js/helper"; import ImageList from "@/lib/ImageList.svelte"; import PaginationBar from "@/lib/PaginationBar.svelte"; import { querystring } from "svelte-spa-router"; @@ -10,7 +10,7 @@ let currentPage; let lastPage; $: if ($querystring !== "") - currentPage = parseInt(new URLSearchParams($querystring).get("p")); + currentPage = parseInt(getQueryValue($querystring, "p")); $: getPageSnowflakes(currentPage - 1).then( (snowflakes) => (pageSnowflakes = snowflakes || []) ); diff --git a/src/static/js/helper.js b/src/static/js/helper.js index 02e9aa493162cdfdc16dbc29327761759b663fa1..334fe455d723bf6438b0f7ce171509a3ff0ccd1c 100644 --- a/src/static/js/helper.js +++ b/src/static/js/helper.js @@ -9,4 +9,8 @@ async function fetchAPI(endpoint, options) { } } -export { fetchAPI }; \ No newline at end of file +function getQueryValue(querystring, query) { + return new URLSearchParams(querystring).get(query) +} + +export { fetchAPI, getQueryValue }; \ No newline at end of file