Skip to content

Commit

Permalink
render do not overide link's target attribute close #370
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-peugnet committed Dec 24, 2023
1 parent d9674c9 commit 9c96b22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/class/Servicerender.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ protected function htmlparser(string $html): string
$href = $link->getAttribute('href');
if (preg_match('~^https?:\/\/~', $href)) {
$classes[] = 'external';
if ($this->externallinkblank) {
if (!$link->hasAttribute('target') && $this->externallinkblank) {
$link->setAttribute('target', '_blank');
}
} elseif (preg_match('~^([a-z0-9-_]+)((\/?#[a-z0-9-_]+)|(\/([\w\-\%\[\]\=\?\&]*)))?$~', $href, $out)) {
Expand All @@ -415,7 +415,7 @@ protected function htmlparser(string $html): string
$classes[] = 'existnot';
// TODO: store internal link that exist not in $this
}
if ($this->internallinkblank) {
if (!$link->hasAttribute('target') && $this->internallinkblank) {
$link->setAttribute('target', '_blank');
}
// Links pointing to medias
Expand Down

0 comments on commit 9c96b22

Please sign in to comment.