fix SearchKeyWordUtils
Showing
1 changed file
with
4 additions
and
6 deletions
@@ -2,6 +2,7 @@ package com.yoho.search.service.utils; | @@ -2,6 +2,7 @@ package com.yoho.search.service.utils; | ||
2 | 2 | ||
3 | import java.io.UnsupportedEncodingException; | 3 | import java.io.UnsupportedEncodingException; |
4 | import java.net.URLDecoder; | 4 | import java.net.URLDecoder; |
5 | +import java.nio.charset.StandardCharsets; | ||
5 | import java.util.Map; | 6 | import java.util.Map; |
6 | 7 | ||
7 | import org.apache.commons.lang.StringUtils; | 8 | import org.apache.commons.lang.StringUtils; |
@@ -19,21 +20,18 @@ public class SearchKeyWordUtils { | @@ -19,21 +20,18 @@ public class SearchKeyWordUtils { | ||
19 | } | 20 | } |
20 | // 编码转换 | 21 | // 编码转换 |
21 | String is_encode = paramMap.get("is_encode"); | 22 | String is_encode = paramMap.get("is_encode"); |
22 | - if (StringUtils.isNotBlank(is_encode) && is_encode.equals("1")) { | 23 | + if ("1".equals(is_encode)) { |
23 | try { | 24 | try { |
24 | - keyword = URLDecoder.decode(keyword, "UTF-8"); | 25 | + keyword = URLDecoder.decode(keyword, StandardCharsets.UTF_8.name()); |
25 | } catch (UnsupportedEncodingException e) { | 26 | } catch (UnsupportedEncodingException e) { |
26 | logger.warn(e.getMessage(), e); | 27 | logger.warn(e.getMessage(), e); |
27 | } | 28 | } |
28 | } | 29 | } |
29 | - if (keyword.contains("%")) { | ||
30 | - keyword.replace("%", "percent");// 特殊处理 | ||
31 | - } | ||
32 | if (keyword.equals("耐克")) { | 30 | if (keyword.equals("耐克")) { |
33 | keyword = "nike"; | 31 | keyword = "nike"; |
34 | } | 32 | } |
35 | keyword = keyword.toLowerCase(); | 33 | keyword = keyword.toLowerCase(); |
36 | return keyword; | 34 | return keyword; |
37 | } | 35 | } |
38 | - | 36 | + |
39 | } | 37 | } |
-
Please register or login to post a comment