Skip to content

Commit

Permalink
fix link geneartion
Browse files Browse the repository at this point in the history
and update test snapshot – not sure why this was necessary, though ¯\_(ツ)_/¯
  • Loading branch information
tyrasd committed Jul 2, 2024
1 parent 7a3afe1 commit bdac21d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions js/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ export function featurePopupContent(feature: GeoJSON.Feature) {
(k.match(/(^|:)wikipedia$/) &&
(wiki_lang = v.match(/^([a-zA-Z]+):(.*)$/)) &&
(wiki_page = wiki_lang[2]))
)
) {
wiki_page = wiki_page.replace(/#.*$/, (match) =>
// 'Target page#Section header' -> 'Target page#Section_header'
match.replace(/ /g, "_")
); // 'Target page#Section header' -> 'Target page#Section_header'
v = `<a href="//${wiki_lang[1]}.wikipedia.org/wiki/${wiki_page}" target="_blank">${v}</a>`;
);
v = `<a href="//${wiki_lang[1]}.wikipedia.org/wiki/${wiki_page}" target="_blank">${v}</a>`;
}
// hyperlinks for wikidata entries
if (k.match(/(^|:)wikidata$/))
v = v.replace(
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/test.popup.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`featurePopupContent > 1`] = `"<h4 class="title is-4"><span class="t" data-t="popup.node">Node</span> <a href="//www.openstreetmap.org/node/270198479" target="_blank">270198479</a> <a href="//www.openstreetmap.org/edit?node=270198479" target="_blank">✏</a></h4><h5 class="subtitle is-5"><span class="t" data-t="popup.tags">Tags</span> <span class="tag is-info is-light">3</span></h5><ul><li><span class="is-family-monospace">amenity = drinking_water</span></li><li><span class="is-family-monospace">fountain = roman_wolf</span></li><li><span class="is-family-monospace">wikimedia_commons = <a href="//commons.wikimedia.org/wiki/File:Roman Wolf Fountain, Villa Celimontana, Roma, Italia Sep 01, 2020 12-41-19 PM.jpeg" target="_blank">File:Roman Wolf Fountain, Villa Celimontana, Roma, Italia Sep 01, 2020 12-41-19 PM.jpeg</a></span></li></ul><h4 class="subtitle is-5"><span class="t" data-t="popup.metadata">Metadata</span></h4><ul><li><span class="is-family-monospace">timestamp = 2022-10-03T09:17:16Z</span></li><li><span class="is-family-monospace">version = 4</span></li><li><span class="is-family-monospace">changeset = <a href="//www.openstreetmap.org/changeset/126925539" target="_blank">126925539</a></span></li><li><span class="is-family-monospace">user = <a href="//www.openstreetmap.org/user/Friendly_Ghost" target="_blank">Friendly_Ghost</a></span></li><li><span class="is-family-monospace">uid = 10875409</span></li></ul><h3 class="subtitle is-5"><span class="t" data-t="popup.coordinates">Coordinates</span></h3><p><a href="geo:41.8837598,12.4947844">41.8837598 / 12.4947844</a> <small>(lat/lon)</small></p>"`;
exports[`featurePopupContent > 1`] = `"<h4 class=\\"title is-4\\"><span class=\\"t\\" data-t=\\"popup.node\\">Node</span> <a href=\\"//www.openstreetmap.org/node/270198479\\" target=\\"_blank\\">270198479</a> <a href=\\"//www.openstreetmap.org/edit?node=270198479\\" target=\\"_blank\\">✏</a></h4><h5 class=\\"subtitle is-5\\"><span class=\\"t\\" data-t=\\"popup.tags\\">Tags</span> <span class=\\"tag is-info is-light\\">3</span></h5><ul><li><span class=\\"is-family-monospace\\">amenity = drinking_water</span></li><li><span class=\\"is-family-monospace\\">fountain = roman_wolf</span></li><li><span class=\\"is-family-monospace\\">wikimedia_commons = <a href=\\"//commons.wikimedia.org/wiki/File:Roman Wolf Fountain, Villa Celimontana, Roma, Italia Sep 01, 2020 12-41-19 PM.jpeg\\" target=\\"_blank\\">File:Roman Wolf Fountain, Villa Celimontana, Roma, Italia Sep 01, 2020 12-41-19 PM.jpeg</a></span></li></ul><h4 class=\\"subtitle is-5\\"><span class=\\"t\\" data-t=\\"popup.metadata\\">Metadata</span></h4><ul><li><span class=\\"is-family-monospace\\">timestamp = 2022-10-03T09:17:16Z</span></li><li><span class=\\"is-family-monospace\\">version = 4</span></li><li><span class=\\"is-family-monospace\\">changeset = <a href=\\"//www.openstreetmap.org/changeset/126925539\\" target=\\"_blank\\">126925539</a></span></li><li><span class=\\"is-family-monospace\\">user = <a href=\\"//www.openstreetmap.org/user/Friendly_Ghost\\" target=\\"_blank\\">Friendly_Ghost</a></span></li><li><span class=\\"is-family-monospace\\">uid = 10875409</span></li></ul><h3 class=\\"subtitle is-5\\"><span class=\\"t\\" data-t=\\"popup.coordinates\\">Coordinates</span></h3><p><a href=\\"geo:41.8837598,12.4947844\\">41.8837598 / 12.4947844</a> <small>(lat/lon)</small></p>"`;

exports[`featurePopupContent > 2`] = `"<h4 class="title is-4"><span class="t" data-t="popup.relation">Relation</span> <a href="//www.openstreetmap.org/relation/1243821" target="_blank">1243821</a> <a href="//www.openstreetmap.org/edit?relation=1243821" target="_blank">✏</a></h4><h5 class="subtitle is-5"><span class="t" data-t="popup.tags">Tags</span> <span class="tag is-info is-light">20</span></h5><ul><li><span class="is-family-monospace">architect = André and Jean Polak</span></li><li><span class="is-family-monospace">architect:wikidata = <a href="//www.wikidata.org/wiki/Q2848896" target="_blank">Q2848896</a></span></li><li><span class="is-family-monospace">building = yes</span></li><li><span class="is-family-monospace">contact:email = <a href="mailto:[email protected]" target="_blank">[email protected]</a></span></li><li><span class="is-family-monospace">contact:phone = <a href="tel:+32 2 475 47 75" target="_blank">+32 2 475 47 75</a></span></li><li><span class="is-family-monospace">contact:website = <a href="https://www.atomium.be/" target="_blank">https://www.atomium.be/</a></span></li><li><span class="is-family-monospace">engineer = André Waterkeyn</span></li><li><span class="is-family-monospace">engineer:wikidata = <a href="//www.wikidata.org/wiki/Q523346" target="_blank">Q523346</a></span></li><li><span class="is-family-monospace">height = 102</span></li><li><span class="is-family-monospace">image = <a href="https://images.mapillary.com/dWS3qotev3rzfk3zwkB0nu/thumb-2048.jpg" target="_blank">https://images.mapillary.com/dWS3qotev3rzfk3zwkB0nu/thumb-2048.jpg</a></span></li><li><span class="is-family-monospace">layer = 1</span></li><li><span class="is-family-monospace">mapillary = <a href="https://www.mapillary.com/app?focus=photo&pKey=291574785922785" target="_blank">291574785922785</a></span></li><li><span class="is-family-monospace">name = Atomium</span></li><li><span class="is-family-monospace">start_date = 1958</span></li><li><span class="is-family-monospace">toilets:wheelchair = yes</span></li><li><span class="is-family-monospace">tourism = attraction</span></li><li><span class="is-family-monospace">type = multipolygon</span></li><li><span class="is-family-monospace">wheelchair = limited</span></li><li><span class="is-family-monospace">wikidata = <a href="//www.wikidata.org/wiki/Q180901" target="_blank">Q180901</a></span></li><li><span class="is-family-monospace">wikipedia = <a href="//fr.wikipedia.org/wiki/Atomium" target="_blank">fr:Atomium</a></span></li></ul><h3 class="subtitle is-5"><span class="t" data-t="popup.coordinates">Coordinates</span></h3><p><a href="geo:50.894924,4.3415237">50.894924 / 4.3415237</a> <small>(lat/lon)</small></p>"`;
exports[`featurePopupContent > 2`] = `"<h4 class=\\"title is-4\\"><span class=\\"t\\" data-t=\\"popup.relation\\">Relation</span> <a href=\\"//www.openstreetmap.org/relation/1243821\\" target=\\"_blank\\">1243821</a> <a href=\\"//www.openstreetmap.org/edit?relation=1243821\\" target=\\"_blank\\">✏</a></h4><h5 class=\\"subtitle is-5\\"><span class=\\"t\\" data-t=\\"popup.tags\\">Tags</span> <span class=\\"tag is-info is-light\\">20</span></h5><ul><li><span class=\\"is-family-monospace\\">architect = André and Jean Polak</span></li><li><span class=\\"is-family-monospace\\">architect:wikidata = <a href=\\"//www.wikidata.org/wiki/Q2848896\\" target=\\"_blank\\">Q2848896</a></span></li><li><span class=\\"is-family-monospace\\">building = yes</span></li><li><span class=\\"is-family-monospace\\">contact:email = <a href=\\"mailto:[email protected]\\" target=\\"_blank\\">[email protected]</a></span></li><li><span class=\\"is-family-monospace\\">contact:phone = <a href=\\"tel:+32 2 475 47 75\\" target=\\"_blank\\">+32 2 475 47 75</a></span></li><li><span class=\\"is-family-monospace\\">contact:website = <a href=\\"https://www.atomium.be/\\" target=\\"_blank\\">https://www.atomium.be/</a></span></li><li><span class=\\"is-family-monospace\\">engineer = André Waterkeyn</span></li><li><span class=\\"is-family-monospace\\">engineer:wikidata = <a href=\\"//www.wikidata.org/wiki/Q523346\\" target=\\"_blank\\">Q523346</a></span></li><li><span class=\\"is-family-monospace\\">height = 102</span></li><li><span class=\\"is-family-monospace\\">image = <a href=\\"https://images.mapillary.com/dWS3qotev3rzfk3zwkB0nu/thumb-2048.jpg\\" target=\\"_blank\\">https://images.mapillary.com/dWS3qotev3rzfk3zwkB0nu/thumb-2048.jpg</a></span></li><li><span class=\\"is-family-monospace\\">layer = 1</span></li><li><span class=\\"is-family-monospace\\">mapillary = <a href=\\"https://www.mapillary.com/app?focus=photo&pKey=291574785922785\\" target=\\"_blank\\">291574785922785</a></span></li><li><span class=\\"is-family-monospace\\">name = Atomium</span></li><li><span class=\\"is-family-monospace\\">start_date = 1958</span></li><li><span class=\\"is-family-monospace\\">toilets:wheelchair = yes</span></li><li><span class=\\"is-family-monospace\\">tourism = attraction</span></li><li><span class=\\"is-family-monospace\\">type = multipolygon</span></li><li><span class=\\"is-family-monospace\\">wheelchair = limited</span></li><li><span class=\\"is-family-monospace\\">wikidata = <a href=\\"//www.wikidata.org/wiki/Q180901\\" target=\\"_blank\\">Q180901</a></span></li><li><span class=\\"is-family-monospace\\">wikipedia = <a href=\\"//fr.wikipedia.org/wiki/Atomium\\" target=\\"_blank\\">fr:Atomium</a></span></li></ul><h3 class=\\"subtitle is-5\\"><span class=\\"t\\" data-t=\\"popup.coordinates\\">Coordinates</span></h3><p><a href=\\"geo:50.894924,4.3415237\\">50.894924 / 4.3415237</a> <small>(lat/lon)</small></p>"`;

0 comments on commit bdac21d

Please sign in to comment.