Skip to content

Commit 2b1e029

Browse files
paladoxgitblit
authored andcommitted
Match longest repository path towards the shortest pr-950
This was originally from gitblit-org#950 but seems to have been reverted when develop branch was merged with master.
1 parent 1fe804a commit 2b1e029

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/main/java/com/gitblit/servlet/RawServlet.java

+6-15
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,14 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
166166
}
167167

168168
// determine repository and resource from url
169-
String repository = "";
169+
String repository = path;
170170
Repository r = null;
171-
int offset = 0;
172-
while (r == null) {
173-
int slash = path.indexOf('/', offset);
174-
if (slash == -1) {
175-
repository = path;
176-
} else {
177-
repository = path.substring(0, slash);
178-
}
179-
offset = ( slash + 1 );
171+
int terminator = repository.length();
172+
do {
173+
repository = repository.substring(0, terminator);
180174
r = repositoryManager.getRepository(repository, false);
181-
if (repository.equals(path)) {
182-
// either only repository in url or no repository found
183-
break;
184-
}
185-
}
175+
terminator = repository.lastIndexOf('/');
176+
} while (r == null && terminator > -1 );
186177

187178
ServletContext context = request.getSession().getServletContext();
188179

0 commit comments

Comments
 (0)