Skip to content

Commit 1bad4d3

Browse files
fixed detail (+) and .q urls so they are based on the current request URL
1 parent e184ad0 commit 1bad4d3

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Diff for: src/main/java/com/hbasebook/hush/HushUtil.java

+9
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,13 @@ public static String getOrSetUsername(HttpServletRequest request,
119119
}
120120
return username;
121121
}
122+
123+
public static String getBaseURL(HttpServletRequest request) {
124+
String url = request.getRequestURI();
125+
int slash = url.lastIndexOf('/');
126+
if (slash < 0) {
127+
slash = url.length();
128+
}
129+
return url.substring(0, slash);
130+
}
122131
}

Diff for: src/main/webapp/details.jsp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<%@ page contentType="text/html;charset=UTF-8" %>
22
<%@ page import="com.hbasebook.hush.ResourceManager" %>
33
<%@ page import="com.hbasebook.hush.Counters" %>
4+
<%@ page import="com.hbasebook.hush.HushUtil" %>
45
<%@ page import="java.text.SimpleDateFormat" %>
56
<%@ page import="java.util.NavigableMap" %>
67
<%@ page import="java.util.Calendar" %>
@@ -30,7 +31,7 @@
3031
forward(request, response);
3132
}
3233
SimpleDateFormat formatter = new SimpleDateFormat("yyyy, MM, dd");
33-
String qrUrl = url.toString() + ".q";
34+
String qrUrl = HushUtil.getBaseURL(request) + "/" + url.getId() + ".q";
3435
ShortUrl aggUrl = manager.getUrlManager().getShortUrl(url.getRefShortId());
3536
%>
3637
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

Diff for: src/main/webapp/include/userstats.jsp

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
<%
99
String username = HushUtil.getOrSetUsername(request, response);
1010
ResourceManager rm = ResourceManager.getInstance();
11-
String requestURI = request.getRequestURI() ;
12-
int endIndex = requestURI.lastIndexOf('/');
13-
if (endIndex < 0)
14-
endIndex = requestURI.length();
15-
String siteUrl = requestURI.substring(0, endIndex) ;
11+
String siteUrl = HushUtil.getBaseURL (request);
1612
String site = rm.getDomainManager().getDefaultDomain();
1713
List<ShortUrlStatistics> stats = rm.getCounters().getUserShortUrlStatistics(
1814
username);

0 commit comments

Comments
 (0)