jenkins-bot has submitted this change and it was merged.

Change subject: T138864: Deal with edge cases serializing links
......................................................................


T138864: Deal with edge cases serializing links

* Updated tests to capture new expectations.

Change-Id: I3f54ab56a1cfd96f35d46a3827bdab00554a0fa3
---
M lib/html2wt/LinkHandler.js
M tests/parserTests.txt
2 files changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Arlolra: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/html2wt/LinkHandler.js b/lib/html2wt/LinkHandler.js
index 71e3b43..e2454d2 100644
--- a/lib/html2wt/LinkHandler.js
+++ b/lib/html2wt/LinkHandler.js
@@ -305,7 +305,8 @@
                // stripped when deriving the content string.
                var strippedTargetValue = target.value.replace(/^:/, '');
                var decodedTarget = Util.decodeEntities(strippedTargetValue);
-               var hrefHasProto = /^\w+:\/\//.test(linkData.href);
+               // Deal with the protocol-relative link scenario as well
+               var hrefHasProto = /^(\w+:)?\/\//.test(linkData.href);
 
                // Normalize content string and decoded target before 
comparison.
                // Piped links don't come down this path => it is safe to 
normalize both.
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 2d76c6f..f5d24f7 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -25022,9 +25022,15 @@
 !! html/parsoid
 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
+<a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
+<a href="http://en.wikipedia.org/wiki/Foo";>http://en.wikipedia.org/wiki/Foo</a>
+<a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
 !! wikitext
 [[Foo]]
 [[Foo]]
+[[:en:Foo|//en.wikipedia.org/wiki/Foo]]
+[[wikipedia:Foo|http://en.wikipedia.org/wiki/Foo]]
+[[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
 !! end
 
 !! test

-- 
To view, visit https://gerrit.wikimedia.org/r/296642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3f54ab56a1cfd96f35d46a3827bdab00554a0fa3
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Cscott <canan...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to