17 lines
638 B
TypeScript
17 lines
638 B
TypeScript
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 {
|
|
return query
|
|
? `${path}?catalogue_query=${encodeURIComponent(query)}`
|
|
: path;
|
|
}
|
|
export function catalogueReturnHref(base: string, pageUrl: string): string {
|
|
const query = new URL(pageUrl, 'https://portal.invalid').searchParams.get(
|
|
'catalogue_query',
|
|
);
|
|
return searchTerritoryHref(
|
|
base + (query ? `?${new URLSearchParams(query).toString()}` : ''),
|
|
pageUrl,
|
|
);
|
|
}
|