From 032f5f7c62ed6932386e700a74dd7e519ad4de5d Mon Sep 17 00:00:00 2001 From: Alex Bitney Date: Sat, 6 Feb 2016 16:33:29 +0200 Subject: domain independence in few places fixed zero tags exception on user's page --- src/main/java/com/juick/http/www/User.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/juick/http/www/User.java') diff --git a/src/main/java/com/juick/http/www/User.java b/src/main/java/com/juick/http/www/User.java index 9ccf43ac..1f2b7dc0 100644 --- a/src/main/java/com/juick/http/www/User.java +++ b/src/main/java/com/juick/http/www/User.java @@ -18,6 +18,7 @@ package com.juick.http.www; import com.juick.Tag; +import com.juick.server.Endpoints; import com.juick.server.MessagesQueries; import com.juick.server.TagQueries; import com.juick.server.UserQueries; @@ -271,7 +272,7 @@ public class User { String hReferer = request.getHeader("Referer"); String ref = Utils.getCookie(request, "ref"); - if (ref == null && (hReferer == null || !(hReferer.startsWith("http://juick.com/") || hReferer.startsWith("https://juick.com/")))) { + if (ref == null && (hReferer == null || !(hReferer.startsWith("http://"+ Endpoints.wwwJuickCom+"/") || hReferer.startsWith("https://"+Endpoints.wwwJuickCom+"/")))) { Cookie c = new Cookie("ref", Integer.toString(uid)); c.setMaxAge(7 * 24 * 60 * 60); c.setPath("/"); @@ -361,7 +362,7 @@ public class User { }), user.getUID()); } - int maxUsageCnt = tags.stream().mapToInt(tag -> tag.UsageCnt).max().getAsInt(); + int maxUsageCnt = tags.size() > 0 ? tags.stream().mapToInt(tag -> tag.UsageCnt).max().getAsInt() : 1; return tags.stream().map(tag -> "" + tag.Name + "") -- cgit v1.2.3