commit16
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
import { searchTerritoryHref } from './search-territory.ts';
|
||||
/** Only a query string is carried; the return destination is always local. */
|
||||
export function catalogueDetailHref(path: string, query: string): string {
|
||||
export function catalogueDetailHref(
|
||||
path: string,
|
||||
query: string,
|
||||
pageUrl?: string,
|
||||
): string {
|
||||
if (pageUrl) {
|
||||
const page = new URL(
|
||||
pageUrl,
|
||||
'https://portal.invalid',
|
||||
).searchParams.get('page');
|
||||
if (
|
||||
page &&
|
||||
/^[1-9]\d*$/.test(page) &&
|
||||
Number.isSafeInteger(Number(page))
|
||||
) {
|
||||
const params = new URLSearchParams(query);
|
||||
params.set('page', page);
|
||||
query = params.toString();
|
||||
}
|
||||
}
|
||||
return query
|
||||
? `${path}?catalogue_query=${encodeURIComponent(query)}`
|
||||
: path;
|
||||
|
||||
Reference in New Issue
Block a user