File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/mapping
grails-web-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,26 @@ mappings {
6969 controller = 'hyphenTests'
7070 action = 'view'
7171 }
72+ "/plugins/grails-$plugin/tags/RELEASE_$version/$fullName(.$type)" {
73+ controller = 'website'
74+ action = 'displayPlugin'
75+ }
7276}
7377'''
74-
78+
79+ void testExtensionPrecededByTokenWhichMayContainDots () {
80+ def holder = new DefaultUrlMappingsHolder (evaluator. evaluateMappings(new ByteArrayResource (mappingScript. bytes)))
81+
82+ def info = holder. match(" /plugins/grails-csv/tags/RELEASE_0.3.1/csv-0.3.1.pom" )
83+ assertNotNull info
84+ assertEquals ' website' , info. controllerName
85+ assertEquals ' displayPlugin' , info. actionName
86+ assertEquals ' 0.3.1' , info. params. version
87+ assertEquals ' csv' , info. params. plugin
88+ assertEquals ' csv-0.3.1' , info. params. fullName
89+ assertEquals ' pom' , info. params. type
90+ }
91+
7592 void testHyphenDelimiters () {
7693 def holder = new DefaultUrlMappingsHolder (evaluator. evaluateMappings(new ByteArrayResource (mappingScript. bytes)))
7794
Original file line number Diff line number Diff line change @@ -228,15 +228,21 @@ protected Pattern convertToRegex(String url) {
228228 .replaceAll ("([^\\ *])\\ *$" , "$1[^/]+" )
229229 .replaceAll ("\\ *\\ *" , ".*" );
230230
231- pattern += urlEnd
231+ if ("/(*)(\\ .(*))" .equals (urlEnd )) {
232+ // shortcut this common special case which will
233+ // happen any time a URL mapping ends with a pattern like
234+ // /$someVariable(.$someExtension)
235+ pattern += "/([^/]+)\\ .([^/.]+)?" ;
236+ } else {
237+ pattern += urlEnd
232238 .replace ("(\\ .(*))" , "\\ .?([^/]+)?" )
233239 .replaceAll ("([^\\ *])\\ *([^\\ *])" , "$1[^/]+$2" )
234240 .replaceAll ("([^\\ *])\\ *$" , "$1[^/]+" )
235241 .replaceAll ("\\ *\\ *" , ".*" )
236242 .replaceAll ("\\ (\\ [\\ ^\\ /\\ ]\\ +\\ )\\ \\ \\ ." , "([^/.]+)\\ \\ ." )
237243 .replaceAll ("\\ (\\ [\\ ^\\ /\\ ]\\ +\\ )\\ ?\\ \\ \\ ." , "([^/.]+)\\ ?\\ \\ ." )
238244 ;
239-
245+ }
240246 pattern += "/??$" ;
241247 regex = Pattern .compile (pattern );
242248 }
You can’t perform that action at this time.
0 commit comments