jdaugherty commented on code in PR #15791:
URL: https://github.com/apache/grails-core/pull/15791#discussion_r3498393663


##########
grails-gsp/plugin/src/main/groovy/org/grails/plugins/web/taglib/UrlMappingTagLib.groovy:
##########
@@ -80,8 +80,20 @@ class UrlMappingTagLib implements TagLibrary {
                 id: attrs.id as String,
                 params: attrs.params as Map)
 
-            if (attrs.namespace != null) {
-                mapping.namespace = attrs.namespace as String
+            // Honor an explicit namespace so a blank one (namespace="" or 
namespace: null) opts out to
+            // the non-namespaced controller; otherwise infer the namespace 
for the target controller so
+            // g:include stays consistent with link generation.
+            if (attrs.containsKey('namespace')) {

Review Comment:
   The existing pattern is to actually fetch the key and only execute the code 
if it's set. The below controller namespace default code will be skipped if 
namespace = '' 



##########
grails-test-examples/namespaces/grails-app/controllers/UrlMappings.groovy:
##########
@@ -30,6 +30,10 @@ class UrlMappings {
             namespace = "admin"
         }
 
+        "/frontend/$controller/$action?/$id?(.$format)?"{
+            namespace = "frontend"

Review Comment:
   namespaces in spring boot can be set by path / header / configured 
statically.  I'm guessing this support is static only? 



##########
grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultLinkGenerator.groovy:
##########
@@ -247,12 +257,20 @@ class DefaultLinkGenerator implements LinkGenerator, 
PluginManagerAware {
                     params.put(ATTRIBUTE_ID, id)
                 }
                 def pluginName = attrs.get(UrlMapping.PLUGIN)?.toString()
-                def namespace = attrs.get(UrlMapping.NAMESPACE)?.toString()
-                if (namespace == null) {
-                    if (controller == 
requestStateLookupStrategy.controllerName) {
-                        namespace = 
requestStateLookupStrategy.controllerNamespace
+                // An explicit namespace attribute always wins so that a blank 
one (namespace="" or

Review Comment:
   This code looks copied from another area.  Why are we implementing the same 
logic multiple times? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to