Skip to content

Commit b79d87c

Browse files
author
Blundell
committed
remove urls from the text
if no text is left, add a witty message
1 parent 3403d40 commit b79d87c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

enews/enews-java/article-editor/src/main/java/com/novoda/enews/ArticleEditor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ private String generateImageUrl(ChannelHistory.Message message) {
3535
}
3636

3737
private String generateText(ChannelHistory.Message message) {
38-
return message.getText()
38+
String text = message.getText()
3939
.replaceAll("<h", "h")
4040
.replaceAll("/>", "")
4141
.replaceAll(">", "")
42-
.replaceAll("\\?(.*)", "");
42+
.replaceAll("\\?(.*)", "")
43+
.replaceAll("(http|https)://(.*)", "");
44+
if(text.isEmpty()) {
45+
return "I was so excited by this #enews, I didn't have time to write anything. Check it out!";
46+
}
47+
return text;
4348
}
4449

4550
private String generateTitle(ChannelHistory.Message message) {

0 commit comments

Comments
 (0)