diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessor.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessor.java index 24baa016..689d7fd8 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessor.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessor.java @@ -1,28 +1,26 @@ package it.niedermann.owncloud.notes.shared.util.text; -import java.util.regex.Matcher; +import androidx.annotation.NonNull; + import java.util.regex.Pattern; public class WwwLinksProcessor extends TextProcessor { - public static final String WWW_URLS_PROTOCOL_PREFIX = "http://"; - private static final String replaceWwwUrlsRegEx = "\\[([^]]*)]\\((www\\..+)\\)"; + private static final String WWW_URLS_PROTOCOL_PREFIX = "https://"; + private static final String REGEX_REPLACE_WWW_URLS = "\\[([^]]*)]\\((www\\..+)\\)"; /** * Prefixes all links, that not not start with a protocol identifier, but with "www." with http:// - * + *

* See https://github.com/stefan-niedermann/nextcloud-notes/issues/949 * * @return Markdown with all pseudo-links replaced through actual HTTP-links */ @Override public String process(String s) { - return replaceWwwUrls(s); - } - - private static String replaceWwwUrls(String markdown) { - Pattern replacePattern = Pattern.compile(replaceWwwUrlsRegEx); - Matcher replaceMatcher = replacePattern.matcher(markdown); - return replaceMatcher.replaceAll(String.format("[$1](%s$2)", WWW_URLS_PROTOCOL_PREFIX)); + return Pattern + .compile(REGEX_REPLACE_WWW_URLS) + .matcher(s) + .replaceAll(String.format("[$1](%s$2)", WWW_URLS_PROTOCOL_PREFIX)); } } diff --git a/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/TextProcessorChainTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/TextProcessorChainTest.java index 6565223e..fcf38718 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/TextProcessorChainTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/TextProcessorChainTest.java @@ -18,7 +18,7 @@ public class TextProcessorChainTest extends TestCase { Assert.assertEquals("SelfIdentifyingProcessor 1\nSelfIdentifyingProcessor 2", chain.apply("")); } - class SelfIdentifyingProcessor extends TextProcessor { + static class SelfIdentifyingProcessor extends TextProcessor { private int id; public SelfIdentifyingProcessor(int id) { diff --git a/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessorTest.java b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessorTest.java index 1c31025c..1e06bc3c 100644 --- a/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessorTest.java +++ b/app/src/test/java/it/niedermann/owncloud/notes/shared/util/text/WwwLinksProcessorTest.java @@ -37,13 +37,12 @@ public class WwwLinksProcessorTest extends TestCase { Assert.assertEquals(markdown, sut.process(markdown)); } - @SuppressWarnings("MarkdownUnresolvedFileReference") public void testDoNotReplaceNormalLinks() { TextProcessor sut = new WwwLinksProcessor(); //language=md String markdown = "[normal link](https://example.com) and another [www link](www.example.com) and one more [normal link](https://www.example.com)"; String result = sut.process(markdown); - Assert.assertEquals("[normal link](https://example.com) and another [www link](http://www.example.com) and one more [normal link](https://www.example.com)", result); + Assert.assertEquals("[normal link](https://example.com) and another [www link](https://www.example.com) and one more [normal link](https://www.example.com)", result); } } \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/2017000.txt b/fastlane/metadata/android/en-US/changelogs/2017000.txt new file mode 100644 index 00000000..ba3b3339 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/2017000.txt @@ -0,0 +1,2 @@ +- Selecting a note in the main note list highlights two notes (#920) (@muety) +- Support www links without protocol in preview mode (#949) (@muety) \ No newline at end of file