add new parameter to support original uri and git-uri LB algorithm
diff --git a/src/backend.c b/src/backend.c
index 0a97b64..87dda72 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -199,29 +199,43 @@
 	if (px->uri_len_limit)
 		uri_len = MIN(uri_len, px->uri_len_limit);
 
-	start = uri;
-	end = uri + uri_len - 1;
-	while (uri_len--) {
-		c = *end;
-		if (c == '/') {
-			slashes++;
-			if (slashes == depth)
+	start = end = uri;
+	if (px->uri_git == 1) {
+		end = uri + uri_len - 1;
+		while (uri_len--) {
+			c = *end;
+			if (c == '/') {
+				slashes++;
+				if (slashes == depth)
+					break;
+			}
+			else if (c == '?')
+				depth = 2;
+			end--;
+		}
+		//get rid of redundant '/'
+		while ((end - start) > 1 && *(start+1) == '/')
+			start++;
+		while ((end - start) > 1 && *(end-1) == '/')
+			end--;
+		//get rid of trailing ".git"
+		if ((end - start) > 4 && strncmp(end-4, ".git", 4) == 0)
+			end -= 4;
+
+	} else {
+		while (uri_len--) {
+			c = *end;
+			if (c == '/') {
+				slashes++;
+				if (slashes == px->uri_dirs_depth1) /* depth+1 */
+					break;
+			}
+			else if (c == '?' && !px->uri_whole)
 				break;
+			end++;
 		}
-		else if (c == '?')
-			depth = 2;
-		end--;
 	}
 	
-	//get rid of redundant '/'
-	while ((end - start) > 1 && *(start+1) == '/')
-		start++;
-	while ((end - start) > 1 && *(end-1) == '/')
-		end--;
-	//get rid of trailing ".git"
-	if ((end - start) > 4 && strncmp(end-4, ".git", 4) == 0)
-		end -= 4;
-
 	hash = gen_hash(px, start, (end - start));
 
 	if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
@@ -1370,6 +1384,7 @@
 		curproxy->lbprm.algo |= BE_LB_ALGO_UH;
 
 		curproxy->uri_whole = 0;
+		curproxy->uri_git = 1;
 
 		while (*args[arg]) {
 			if (!strcmp(args[arg], "len")) {
@@ -1379,6 +1394,7 @@
 				}
 				curproxy->uri_len_limit = atoi(args[arg+1]);
 				arg += 2;
+				curproxy->uri_git = 0;
 			}
 			else if (!strcmp(args[arg], "depth")) {
 				if (!*args[arg+1] || (atoi(args[arg+1]) <= 0)) {
@@ -1390,10 +1406,12 @@
 				 */
 				curproxy->uri_dirs_depth1 = atoi(args[arg+1]) + 1;
 				arg += 2;
+				curproxy->uri_git = 0;
 			}
 			else if (!strcmp(args[arg], "whole")) {
 				curproxy->uri_whole = 1;
 				arg += 1;
+				curproxy->uri_git = 0;
 			}
 			else {
 				memprintf(err, "%s only accepts parameters 'len', 'depth', and 'whole' (got '%s').", args[0], args[arg]);