X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/2f8b33afce5cd34432db91fbd4d6950bd38359a3..52521128a144a4e42653e0bf8c6a6f0fddb8a6bc:/src/lib/helpers.js diff --git a/src/lib/helpers.js b/src/lib/helpers.js index dfe4ced..023da09 100644 --- a/src/lib/helpers.js +++ b/src/lib/helpers.js @@ -13,6 +13,15 @@ export function formatOSMType(sType, bExcludeExternal) { return ''; } +// https://www.openstreetmap.org/relation/123 => ['R', 123] +// w123 => ['W', 123] +export function identifyLinkInQuery(query) { + if (!query) return undefined; + const m = query.match(/\/(relation|way|node)\/(\d+)/) || query.match(/^([nwr])(\d+)$/i); + if (!m) return undefined; + return [m[1][0].toUpperCase(), Number(m[2])]; +} + export function osmLink(aPlace) { if (!aPlace.osm_type) return ''; var sOSMType = formatOSMType(aPlace.osm_type, false);