This commit is contained in:
Luca Frosini 2021-01-15 10:47:39 +01:00
parent 2692ae036e
commit 81c7b28c62
2 changed files with 30 additions and 9 deletions

View File

@ -21,8 +21,6 @@ public class SanitizedURL {
throw new MalformedURLException();
}
prefix = urlString.substring(0,1);
if(prefix.matches(CHARACTERS_TO_REMOVE)) {
prefix = urlString.substring(0, 1);
@ -35,16 +33,22 @@ public class SanitizedURL {
urlString = "http://" + urlString;
}
postfix = urlString.substring(urlString.length()-1);
if(postfix.matches(CHARACTERS_TO_REMOVE)) {
urlString = urlString.substring(0, urlString.length()-1);
}else {
postfix = "";
}
postfix = "";
urlString = stripPostfix(urlString);
url = new URL(urlString);
}
private String stripPostfix(String urlString) {
String testPostFix = urlString.substring(urlString.length()-1);
if(testPostFix.matches(CHARACTERS_TO_REMOVE)) {
postfix = urlString.substring(urlString.length()-1) + postfix;
urlString = urlString.substring(0, urlString.length()-1);
urlString = stripPostfix(urlString);
}
return urlString;
}
public String getPrefix() {
return prefix;
}

View File

@ -56,6 +56,22 @@ public class MessageParserTest {
public static final String TEST_LUCA_8 = "Hello this link \"https://virtuoso.parthenos.d4science.org/sparql?default-graph-uri=&query=SELECT+%3Ftype+%28COUNT%28%3Ftype%29+as+%3FtypeCount%29++%0D%0A%09%09%09%09%09WHERE+%7B%5B%5D+a+%3Ftype%7D%0D%0A%09%09%09%09%09GROUP+BY+%3Ftype&format=text%2Fhtml&timeout=0&debug=on\" is a SPARQL query ";
public static final String TEST_BUG_18356 = "Dear B-C colleagues,\n"
+ "\n"
+ "Just a kind reminder that we look forward to welcoming all of you during the Projects upcoming Blue-Cloud “Service Exploitation & Sustainability Plan (SE&SP) and Roadmap to 2030” Workshop next Thursday, January 21st (9.30am to 1.30pm). Everyone's welcome for an interactive and productive discussion.\n"
+ "\n"
+ "Please find here a link to the workshop Agenda (https://data.d4science.net/tfXA), including connection details.\n"
+ "\n"
+ "As discussed, the workshop will provide an opportunity to share the high-level results of the initial phase of stakeholder consultations towards the B-C Roadmap and to work within the Partnership to discuss and align some of the underlying, strategic concepts and ideas that will set the direction for the B-C SE&SP and B-C Roadmap to 2030.\n"
+ "\n"
+ "To inform the discussions to be held during the workshop, we have produced a report bringing together all the feedback, messages and recommendations gathered during the initial phase of stakeholder consultations (available here - https://data.d4science.net/JEm7). It is a long document, but we have included a one-page Executive Summary with high-level, key messages & recommendations, in case useful.\n"
+ "\n"
+ "We look forward to a productive discussion with you next Thursday!\n"
+ "\n"
+ "Kind regards,\n"
+ "Julia";
@Test
public void test13() {
SocialMessageParser messageParser = new SocialMessageParser(TEST_13);
@ -105,7 +121,8 @@ public class MessageParserTest {
logger.debug(messageParser.getParsedMessage());
messageParser = new SocialMessageParser(TEST_LUCA_7);
logger.debug("{}", messageParser.getParsedMessage());
messageParser = new SocialMessageParser(TEST_BUG_18356);
logger.debug("{}", messageParser.getParsedMessage());
}
@Test(expected=MalformedURLException.class)