Skip to content

Commit 2097509

Browse files
authored
Merge pull request #75 from common-workflow-language/hotfix-trailslash-dedupe
Remove trailing slashes from submitted URLs
2 parents 0a07912 + e367d92 commit 2097509

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/main/java/org/commonwl/viewer/domain/WorkflowForm.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,32 @@
2525
*/
2626
public class WorkflowForm {
2727

28+
private String githubURL;
29+
2830
public WorkflowForm() {}
2931

3032
public WorkflowForm(String githubURL) {
31-
this.githubURL = githubURL;
33+
if (githubURL != null) {
34+
this.githubURL = trimTrailingSlashes(githubURL);
35+
}
3236
}
3337

34-
private String githubURL;
35-
3638
public String getGithubURL() {
3739
return githubURL;
3840
}
3941

4042
public void setGithubURL(String githubURL) {
41-
this.githubURL = githubURL;
43+
if (githubURL != null) {
44+
this.githubURL = trimTrailingSlashes(githubURL);
45+
}
46+
}
47+
48+
/**
49+
* Cuts any trailing slashes off a string
50+
* @param url The string to cut the slashes off
51+
* @return The same string without trailing slashes
52+
*/
53+
private String trimTrailingSlashes(String url) {
54+
return url.replaceAll("\\/+$", "");
4255
}
4356
}

src/main/java/org/commonwl/viewer/services/GitHubService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.eclipse.egit.github.core.client.GitHubClient;
2727
import org.eclipse.egit.github.core.service.CommitService;
2828
import org.eclipse.egit.github.core.service.ContentsService;
29-
import org.eclipse.egit.github.core.service.RepositoryService;
3029
import org.eclipse.egit.github.core.service.UserService;
3130
import org.springframework.beans.factory.annotation.Autowired;
3231
import org.springframework.beans.factory.annotation.Value;
@@ -53,7 +52,6 @@ public class GitHubService {
5352
private final ContentsService contentsService;
5453
private final UserService userService;
5554
private final CommitService commitService;
56-
private final RepositoryService repoService;
5755

5856
// URL validation for directory links
5957
private final String GITHUB_DIR_REGEX = "^https?:\\/\\/github\\.com\\/([A-Za-z0-9_.-]+)\\/([A-Za-z0-9_.-]+)\\/?(?:(?:tree|blob)\\/([^/]+)\\/(.*))?$";
@@ -73,7 +71,6 @@ public GitHubService(@Value("${githubAPI.authentication}") String authSetting,
7371
this.contentsService = new ContentsService(client);
7472
this.userService = new UserService(client);
7573
this.commitService = new CommitService(client);
76-
this.repoService = new RepositoryService(client);
7774
}
7875

7976
/**

0 commit comments

Comments
 (0)