Skip to content

Commit e367d92

Browse files
author
Mark Robinson
committed
Remove trailing slashes from submitted URLs
1 parent 63a35c9 commit e367d92

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
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
}

0 commit comments

Comments
 (0)