From 477412d32836c6a8821f17ff0c26a3c18843d815 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 05 May 2014 10:32:38 -0400
Subject: [PATCH] Add raw links to branches

---
 src/main/java/com/gitblit/servlet/RawServlet.java |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/gitblit/servlet/RawServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java
index cde7b2e..15e036e 100644
--- a/src/main/java/com/gitblit/servlet/RawServlet.java
+++ b/src/main/java/com/gitblit/servlet/RawServlet.java
@@ -94,7 +94,17 @@
 		if (baseURL.length() > 0 && baseURL.charAt(baseURL.length() - 1) == '/') {
 			baseURL = baseURL.substring(0, baseURL.length() - 1);
 		}
-		String encodedPath = path.replace(' ', '-');
+
+		if (branch != null) {
+			char fsc = '!';
+			char c = GitblitContext.getManager(IRuntimeManager.class).getSettings().getChar(Keys.web.forwardSlashCharacter, '/');
+			if (c != '/') {
+				fsc = c;
+			}
+			branch = branch.replace('/', fsc);
+		}
+
+		String encodedPath = path == null ? "" : path.replace(' ', '-');
 		try {
 			encodedPath = URLEncoder.encode(encodedPath, "UTF-8");
 		} catch (UnsupportedEncodingException e) {
@@ -109,7 +119,8 @@
 		if (fs > -1) {
 			branch = branch.substring(0, fs);
 		}
-		return branch;
+		char c = runtimeManager.getSettings().getChar(Keys.web.forwardSlashCharacter, '/');
+		return branch.replace('!', '/').replace(c, '/');
 	}
 
 	protected String getPath(String repository, String branch, HttpServletRequest request) {

--
Gitblit v1.9.1