mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-23 00:29:50 +02:00
Open all links externally and preserve attrs
This commit is contained in:
@@ -70,9 +70,7 @@ export function uiNoteComments() {
|
||||
.attr('class', 'comment-text')
|
||||
.html(function(d) { return d.html; })
|
||||
.selectAll('a')
|
||||
.filter(isExternalLink)
|
||||
.attr('rel', 'noopener')
|
||||
.attr('rel', 'nofollow')
|
||||
.attr('rel', 'noopener nofollow')
|
||||
.attr('target', '_blank');
|
||||
|
||||
comments
|
||||
@@ -115,22 +113,6 @@ export function uiNoteComments() {
|
||||
}
|
||||
|
||||
|
||||
// A quick test for external links. 'this' is the node passed in by selection.filter()
|
||||
function isExternalLink() {
|
||||
try {
|
||||
// Possibly more domains to be added
|
||||
const internalDomains = ['.openstreetmap.org', '.osm.org'];
|
||||
const hostname = new URL(this.href).hostname;
|
||||
|
||||
// If the link's hostname comprises any internalDomains, return false
|
||||
return internalDomains.findIndex((d) => hostname.includes(d)) === -1;
|
||||
} catch (error) {
|
||||
// If anything goes wrong, bail and assume not external (original behaviour)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
noteComments.note = function(val) {
|
||||
if (!arguments.length) return _note;
|
||||
_note = val;
|
||||
|
||||
Reference in New Issue
Block a user