Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cwp-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
cwp
cwp-core
Commits
cd0aee9a
Commit
cd0aee9a
authored
Mar 15, 2017
by
Robbie Averill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX CWPT-475: Remove extra spaces in external links around nonvisual-indicator span, breaks ::after
parent
ca8af7b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
code/extensions/RichLinksExtension.php
code/extensions/RichLinksExtension.php
+1
-1
tests/RichLinksExtensionTest.php
tests/RichLinksExtensionTest.php
+4
-4
No files found.
code/extensions/RichLinksExtension.php
View file @
cd0aee9a
...
...
@@ -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
);
...
...
tests/RichLinksExtensionTest.php
View file @
cd0aee9a
...
...
@@ -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.'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment