Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match/exclude in interceptors don't correctly read the controllername when having hyphenated url converter #11165

Open
olavgg opened this issue Nov 23, 2018 · 3 comments

Comments

@olavgg
Copy link

olavgg commented Nov 23, 2018

Steps to Reproduce

  1. open LogEnvController index action

Expected Behaviour

In Grails when you refer to controller names, you use non-hyphenated references. For example with the createLink taglib or in URLMappings.

Actual Behaviour

But Interceptors match only work if you match with the hyphenated uri reference of the controller name.
When I see in the code (org.grails.plugins.web.interceptors.UrlMappingMatcher) it only seem to run the match against the request uri.

So in conclusion:
match(controller: "logEnvSwitch", action: "") does not work
match(controller: "log-env-switch", action: "
") work

Consistent behavior would be support for both?

Environment Information

  • Operating System: Ubuntu 18.04 64bits
  • Grails Version: 3.3.8
  • JDK Version: OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13)

Example Application

https://github.com/olavgg/hyphenatedinterceptorbug

@osscontributor
Copy link
Member

match(controller: "logEnvSwitch", action: "") does not work
match(controller: "log-env-switch", action: "") work

Consistent behavior would be support for both?

I do not think the behavior should be consistent for both. I think "logEnvSwitch" should be made to work. I don't think "log-env-switch" is intended to be supported. The value is supposed to be the property name version of the controller name and shouldn't have anything to do with URL mapping.

@olavgg
Copy link
Author

olavgg commented Nov 24, 2018

I agree with you, I don't think hyphenated references would work for taglibs or in URL mapping, which means supporting it in interceptors will only add more confusion.

@olavgg
Copy link
Author

olavgg commented Dec 19, 2018

I want to give an update as I am working on resolving this.

controllerName, actionName and namespace also prints the hyphenated names inside the interceptor. This may be the reason the matching is also not working, though I have not managed to figure out that part yet.

Anyway in DefaultUrlMappingInfo in the getControllerName, getActionName and getNamspace methods, I have added a hyphenated to camel case converter olavgg@6989cf3#diff-4d4ad4c96b2a8d7368334cdf04d21fdb

This seems to resolve the issue with controllerName, actionName and controllerNamespace inside the interceptor.

I feel I am in deep water here with my changes, I know there is some code duplication here but would like some feedback if this looks correct before refactoring it.

The bug with matching is something I need to look further into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants