From 01e63f68c21592615a41e84826e494072c5ddc19 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 18 Mar 2025 09:31:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0https?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cultural/heritage/utils/RegexUtils.java | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/cultural/heritage/utils/RegexUtils.java b/src/main/java/com/cultural/heritage/utils/RegexUtils.java index 6bc5126..8916b9a 100644 --- a/src/main/java/com/cultural/heritage/utils/RegexUtils.java +++ b/src/main/java/com/cultural/heritage/utils/RegexUtils.java @@ -2,9 +2,6 @@ package com.cultural.heritage.utils; import org.apache.commons.lang3.StringUtils; -import java.util.HashMap; -import java.util.Map; - import static com.cultural.heritage.constant.RegexConstant.*; @@ -64,22 +61,8 @@ public class RegexUtils { public static String encodeUrl(String input) { - Map replaceMap = new HashMap<>(); - replaceMap.put(" ", "%20"); - replaceMap.put("\\+", "%2B"); - replaceMap.put("\\?", "%3F"); - replaceMap.put("#", "%23"); - replaceMap.put("&", "%26"); - replaceMap.put("/", "%2F"); - replaceMap.put(":", "%3A"); - replaceMap.put("\\(", "%28"); - replaceMap.put("\\)", "%29"); - replaceMap.put("!", "%21"); - - for (Map.Entry entry : replaceMap.entrySet()) { - input = input.replaceAll(entry.getKey(), entry.getValue()); - } - return input; + String regex = input.replaceAll("[^a-zA-Z0-9]", "_"); + return input.replaceAll(regex, "_"); }