From 8483e0b86a74e31f1358edcb882ba46cf1cc6672 Mon Sep 17 00:00:00 2001 From: Winston Li Date: Thu, 20 Nov 2014 11:37:32 +0000 Subject: [PATCH] Accounting for trailing slashes and .git in project name. --- .../git/handler/WLRepositoryResolver.java | 3 ++- .../src/uk/ac/ic/wlgitbridge/util/Util.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java index ef05f36bc3..95074eccca 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java @@ -8,6 +8,7 @@ import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import uk.ac.ic.wlgitbridge.bridge.RepositorySource; import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException; +import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.writelatex.SnapshotRepositoryBuilder; import javax.servlet.http.HttpServletRequest; @@ -29,7 +30,7 @@ public class WLRepositoryResolver implements RepositoryResolver -1) { + result = result.substring(0, lastIndexOfSuffix); + } + return result; + } + + /* removeAllSuffixes("something.git///", "/", ".git") => "something" */ + public static String removeAllSuffixes(String str, String... suffixes) { + String result = str; + for (String suffix : suffixes) { + result = removeAllSuffix(result, suffix); + } + return result; + } + }