X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/f51f2a70794858f9c8fb5d75ecd40fd1e4ec3897..9f280ac8ee3878fa1774be452a879e6d37b67510:/src/components/DetailsLink.svelte
diff --git a/src/components/DetailsLink.svelte b/src/components/DetailsLink.svelte
index 51a0c8c..d914079 100644
--- a/src/components/DetailsLink.svelte
+++ b/src/components/DetailsLink.svelte
@@ -4,7 +4,8 @@
export let extra_classes = '';
export let feature = null;
- let url_params = '';
+ let url_params = new URLSearchParams();
+ let href = 'details.html';
function formatShortOSMType(sType) {
if (sType === 'node') return 'N';
@@ -14,29 +15,38 @@
}
function handleClick() {
- window.history.pushState([], '', 'details.html' + url_params);
- refresh_page();
+ refresh_page('details', url_params);
}
$: {
- if (feature !== null && feature.osm_type) {
- let param = '?osmtype=';
- if (feature.osm_type.length == 1) {
- param += encodeURIComponent(feature.osm_type);
- } else {
- param += formatShortOSMType(feature.osm_type);
- }
- param += '&osmid=' + encodeURIComponent(feature.osm_id);
- if (feature.class) {
- param += '&class=' + encodeURIComponent(feature.class);
- } else if (feature.category) {
- param += '&class=' + encodeURIComponent(feature.category);
+ let new_params = new URLSearchParams();
+
+ if (feature !== null) {
+ if (feature.osm_type) {
+ if (feature.osm_type.length === 1) {
+ new_params.set('osmtype', feature.osm_type);
+ } else {
+ new_params.set('osmtype', formatShortOSMType(feature.osm_type));
+ }
+
+ new_params.set('osmid', feature.osm_id);
+
+ if (feature.class) {
+ new_params.set('class', feature.class);
+ } else if (feature.category) {
+ new_params.set('class', feature.category);
+ }
+ } else if (feature.place_id) {
+ new_params.set('place_id', feature.place_id);
}
- url_params = param
- } else {
- url_params = '';
}
- }
+ url_params = new_params;
+ }
+
+ $: {
+ let param_str = url_params.toString();
+ href = 'details.html' + (param_str ? '?' : '') + param_str;
+ }
-
+