|
15 | 15 | */ |
16 | 16 | package org.grails.web.mapping; |
17 | 17 |
|
| 18 | +import java.util.LinkedHashMap; |
18 | 19 | import java.util.Map; |
19 | 20 |
|
20 | 21 | import grails.util.GrailsStringUtils; |
@@ -100,24 +101,25 @@ private boolean isCacheable(Map attrs) { |
100 | 101 | } |
101 | 102 |
|
102 | 103 | // Based on DGM toMapString, but with StringBuilder instead of StringBuffer |
103 | | - private void appendMapKey(StringBuilder buffer, Map map) { |
104 | | - if (map==null || map.isEmpty()) { |
| 104 | + private void appendMapKey(StringBuilder buffer, Map<String, Object> params) { |
| 105 | + if (params==null || params.isEmpty()) { |
105 | 106 | buffer.append(EMPTY_MAP_STRING); |
106 | | - } |
107 | | - final String requestControllerName = getRequestStateLookupStrategy().getControllerName(); |
108 | | - if (map.get(UrlMapping.ACTION) != null && map.get(UrlMapping.CONTROLLER) == null) { |
109 | | - Object action = map.remove(UrlMapping.ACTION); |
110 | | - map.put(UrlMapping.CONTROLLER, requestControllerName); |
111 | | - map.put(UrlMapping.ACTION, action); |
112 | | - } |
113 | | - if (map.get(UrlMapping.NAMESPACE) == null && map.get(UrlMapping.CONTROLLER) == requestControllerName) { |
114 | | - String namespace = getRequestStateLookupStrategy().getControllerNamespace(); |
115 | | - if (GrailsStringUtils.isNotEmpty(namespace)) { |
116 | | - map.put(UrlMapping.NAMESPACE, namespace); |
| 107 | + buffer.append(OPENING_BRACKET); |
| 108 | + } else { |
| 109 | + buffer.append(OPENING_BRACKET); |
| 110 | + Map map = new LinkedHashMap<>(params); |
| 111 | + final String requestControllerName = getRequestStateLookupStrategy().getControllerName(); |
| 112 | + if (map.get(UrlMapping.ACTION) != null && map.get(UrlMapping.CONTROLLER) == null && map.get(RESOURCE_PREFIX) == null) { |
| 113 | + Object action = map.remove(UrlMapping.ACTION); |
| 114 | + map.put(UrlMapping.CONTROLLER, requestControllerName); |
| 115 | + map.put(UrlMapping.ACTION, action); |
| 116 | + } |
| 117 | + if (map.get(UrlMapping.NAMESPACE) == null && map.get(UrlMapping.CONTROLLER) == requestControllerName) { |
| 118 | + String namespace = getRequestStateLookupStrategy().getControllerNamespace(); |
| 119 | + if (GrailsStringUtils.isNotEmpty(namespace)) { |
| 120 | + map.put(UrlMapping.NAMESPACE, namespace); |
| 121 | + } |
117 | 122 | } |
118 | | - } |
119 | | - buffer.append(OPENING_BRACKET); |
120 | | - if (map != null) { |
121 | 123 | boolean first = true; |
122 | 124 | for (Object o : map.entrySet()) { |
123 | 125 | Map.Entry entry = (Map.Entry) o; |
|
0 commit comments