Commit cd0aee9a authored by Robbie Averill's avatar Robbie Averill

FIX CWPT-475: Remove extra spaces in external links around nonvisual-indicator span, breaks ::after

parent ca8af7b2
......@@ -38,7 +38,7 @@ class RichLinksExtension extends Extension {
// Inject extra attributes into the external links.
$pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU';
$replacement = sprintf(
'$1class="external" rel="external" title="%s" $2 <span class="nonvisual-indicator">(external link)</span> $3',
'$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3',
_t('RichLinks.OpenLinkTitle', 'Open external link')
);
$content = preg_replace($pattern, $replacement, $content, -1);
......
......@@ -9,16 +9,16 @@ class RichLinksExtensionTest extends SapphireTest {
$field->setValue('<a href="http://newzealand.govt.nz">New Zealand Government</a>');
$this->assertEquals(
$field->RichLinks(),
'<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz">New Zealand Government '
.'<span class="nonvisual-indicator">(external link)</span> </a>',
'<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz">New Zealand Government'
.'<span class="nonvisual-indicator">(external link)</span></a>',
'Injects attributes to external link without target.'
);
$field->setValue('<a href="http://newzealand.govt.nz" target="_blank">New Zealand Government</a>');
$this->assertEquals(
$field->RichLinks(),
'<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz" target="_blank">New Zealand Government '
.'<span class="nonvisual-indicator">(external link)</span> </a>',
'<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz" target="_blank">New Zealand Government'
.'<span class="nonvisual-indicator">(external link)</span></a>',
'Injects attributes to external link with target, while keeping the existing attributes.'
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment