]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/lib/stores.js
when searching for OSM Url, show detail page result page
[nominatim-ui.git] / src / lib / stores.js
index 35344ce7cf97c2473886743c4b3b90dcc60ede69..5e755c1eddfa9c36046e560b121356e81b67a257 100644 (file)
@@ -1,4 +1,5 @@
 import { writable } from 'svelte/store';
+import { identifyLinkInQuery } from './helpers.js';
 
 export const map_store = writable();
 export const results_store = writable();
@@ -54,6 +55,16 @@ export function refresh_page(pagename, params) {
     }
   }
 
+  if (pagename === 'search' && params.has('q')) {
+    const arrTypeAndId = identifyLinkInQuery(params.get('q'));
+    if (arrTypeAndId instanceof Array) {
+      pagename = 'details';
+      params = new URLSearchParams();
+      params.set('osmtype', arrTypeAndId[0]);
+      params.set('osmid', arrTypeAndId[1]);
+    }
+  }
+
   page.set({ tab: pagename, params: params });
   last_api_request_url_store.set(null);
   error_store.set(null);