Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2209] Skip blank lines in blurb file url #2239

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/reposense/parser/BlurbMarkdownParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public BlurbMap parse() throws IOException, InvalidMarkdownException {
// extract the url record first
// this is guaranteed to be in the first line or else we fail
UrlRecord urlRecord = this.getUrlRecord(mdLines, counter);
// if delimiter is the last non-blank line, null is returned
if (urlRecord == null) {
break;
}
url = urlRecord.getUrl();
counter = urlRecord.getNextPosition();

Expand Down Expand Up @@ -120,9 +124,17 @@ private UrlRecord getUrlRecord(List<String> lines, int position) throws InvalidM
// checks if url is valid
// adapted from https://www.baeldung.com/java-validate-url
try {
String url = lines.get(position).strip();
String url = "";
// skips blank lines
while (url.length() == 0) {
// checks if delimiter is the last non-blank line
if (position >= lines.size()) {
return null;
}
url = lines.get(position++).strip();
}
new URL(url).toURI();
return new UrlRecord(lines.get(position), position + 1);
return new UrlRecord(url, position);
} catch (MalformedURLException | URISyntaxException ex) {
throw new InvalidMarkdownException("URL provided is not valid!");
}
Expand Down
1 change: 1 addition & 0 deletions src/systemtest/resources/ConfigSystemTest/blurbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ https://www.github.com/user/repo/branch2

this is what i have done for my cs2103t project
<!--repo-->

https://www.github.com/user/repo/branch3
*third blurb*

Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/BlurbMarkdownParserTest/multiple_blurbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Master branch of testrepo-Beta
https://github.com/reposense/testrepo-Gamma/tree/master
Master branch of testrepo-Gamma
<!--repo-->

https://github.com/reposense/testrepo-Sigma/tree/master
Master branch of testrepo-Sigma
<!--repo-->

Loading