Skip to content

Commit

Permalink
EZP-29843 : avoid double anchor in links
Browse files Browse the repository at this point in the history
Closes #87
  • Loading branch information
tharkun authored and andrerom committed Dec 10, 2018
1 parent ae23c0c commit abe2e5c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/FieldType/XmlText/Converter/EzLinkToHtml5.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ public function convert(DOMDocument $xmlDoc)
}

if ($this->elementHasAttribute($element, 'anchor_name')) {
$element->setAttribute(
'url',
$element->getAttribute('url') . '#' .
$this->getElementAttribute($element, 'anchor_name')
);
$anchor = '#' . $this->getElementAttribute($element, 'anchor_name');
if (strpos($element->getAttribute('url'), $anchor) === false) {
$element->setAttribute(
'url',
$element->getAttribute('url') . '#' .
$this->getElementAttribute($element, 'anchor_name')
);
}
}
}
}
Expand Down

0 comments on commit abe2e5c

Please sign in to comment.