summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-06-28 01:47:51 -0400
committerSaturnino Abril <saturnino.abril@gmail.com>2017-06-28 13:47:51 +0800
commit4484c82b1becc2fe5ab7b6842b3419b16c523445 (patch)
tree33258c309c3a5a558a3c81fec33e7132dac377e1 /webapp
parent99fc4b0988e941242732feff428468c6df69fe50 (diff)
downloadchat-4484c82b1becc2fe5ab7b6842b3419b16c523445.tar.gz
chat-4484c82b1becc2fe5ab7b6842b3419b16c523445.tar.bz2
chat-4484c82b1becc2fe5ab7b6842b3419b16c523445.zip
PLT-6799 Removed <wbr> tags from markdown links (#6766)
* PLT-6799 Removed <wbr> tags from markdown links * Fixed unit tests
Diffstat (limited to 'webapp')
-rw-r--r--webapp/tests/utils/formatting_hashtags.test.jsx6
-rw-r--r--webapp/tests/utils/formatting_links.test.jsx2
-rw-r--r--webapp/utils/text_formatting.jsx12
3 files changed, 4 insertions, 16 deletions
diff --git a/webapp/tests/utils/formatting_hashtags.test.jsx b/webapp/tests/utils/formatting_hashtags.test.jsx
index 917f0135a..cba7322ff 100644
--- a/webapp/tests/utils/formatting_hashtags.test.jsx
+++ b/webapp/tests/utils/formatting_hashtags.test.jsx
@@ -53,7 +53,7 @@ describe('TextFormatting.Hashtags', function() {
assert.equal(
TextFormatting.formatText('#test1/#test2').trim(),
- "<p><a class='mention-link' href='#' data-hashtag='#test1'>#test1</a>/<wbr /><a class='mention-link' href='#' data-hashtag='#test2'>#test2</a></p>"
+ "<p><a class='mention-link' href='#' data-hashtag='#test1'>#test1</a>/<a class='mention-link' href='#' data-hashtag='#test2'>#test2</a></p>"
);
assert.equal(
@@ -137,12 +137,12 @@ describe('TextFormatting.Hashtags', function() {
assert.equal(
TextFormatting.formatText('#foo/#bar', {searchTerm: '#foo'}).trim(),
- "<p><span class='search-highlight'><a class='mention-link' href='#' data-hashtag='#foo'>#foo</a></span>/<wbr /><a class='mention-link' href='#' data-hashtag='#bar'>#bar</a></p>"
+ "<p><span class='search-highlight'><a class='mention-link' href='#' data-hashtag='#foo'>#foo</a></span>/<a class='mention-link' href='#' data-hashtag='#bar'>#bar</a></p>"
);
assert.equal(
TextFormatting.formatText('#foo/#bar', {searchTerm: 'bar'}).trim(),
- "<p><a class='mention-link' href='#' data-hashtag='#foo'>#foo</a>/<wbr /><span class='search-highlight'><a class='mention-link' href='#' data-hashtag='#bar'>#bar</a></span></p>"
+ "<p><a class='mention-link' href='#' data-hashtag='#foo'>#foo</a>/<span class='search-highlight'><a class='mention-link' href='#' data-hashtag='#bar'>#bar</a></span></p>"
);
assert.equal(
diff --git a/webapp/tests/utils/formatting_links.test.jsx b/webapp/tests/utils/formatting_links.test.jsx
index efa66ae6b..c4f949203 100644
--- a/webapp/tests/utils/formatting_links.test.jsx
+++ b/webapp/tests/utils/formatting_links.test.jsx
@@ -489,7 +489,7 @@ describe('Markdown.Links', function() {
it('Searching for links', function(done) {
assert.equal(
TextFormatting.formatText('https://en.wikipedia.org/wiki/Unix', {searchTerm: 'wikipedia'}).trim(),
- '<p><a class="theme markdown__link search-highlight" href="https://en.wikipedia.org/wiki/Unix" rel="noreferrer" target="_blank">https:/<wbr />/<wbr />en.wikipedia.org/<wbr />wiki/<wbr />Unix</a></p>'
+ '<p><a class="theme markdown__link search-highlight" href="https://en.wikipedia.org/wiki/Unix" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Unix</a></p>'
);
assert.equal(
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx
index 5cae81f4e..33cc3242c 100644
--- a/webapp/utils/text_formatting.jsx
+++ b/webapp/utils/text_formatting.jsx
@@ -53,11 +53,6 @@ export function formatText(text, inputOptions) {
output = replaceNewlines(output);
}
- // Add <wbr /> tags to recommend line breaking on slashes within URLs
- if (!options.singleline) {
- output = insertLongLinkWbr(output);
- }
-
return output;
}
@@ -477,10 +472,3 @@ export function replaceTokens(text, tokens) {
function replaceNewlines(text) {
return text.replace(/\n/g, ' ');
}
-
-//replace all "/" inside <a> tags to "/<wbr />"
-function insertLongLinkWbr(test) {
- return test.replace(/\//g, (match, position, string) => {
- return match + ((/a[^>]*>[^<]*$/).test(string.substr(0, position)) ? '<wbr />' : '');
- });
-}