File tree 2 files changed +4
-2
lines changed
main/java/com/coditory/quark/i18n/loader
test/groovy/com/coditory/quark/i18n/loader
2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ private I18nPath extractPath(Matcher matcher) {
165
165
String prefix = null ;
166
166
if (activeGroups .containsKey (PREFIXES_GROUP_MARKER )) {
167
167
String prefixesMatch = matcher .group ("prefixes" );
168
- if (prefixesMatch != null && !prefixesMatch .equals ("/" )) {
168
+ if (prefixesMatch != null && !prefixesMatch .isEmpty () && ! prefixesMatch . equals ("/" )) {
169
169
prefix = prefixesMatch .substring (0 , prefixesMatch .length () - 1 );
170
170
}
171
171
}
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class I18nPathPatternSpec extends Specification {
42
42
" /abc/*.json" | " /abc/x.json.json"
43
43
" /abc/*.*.json" | " /abc/x.xml.json"
44
44
// capturing groups
45
+ " /abc/{prefixes}/i18n.json" | " /abc/i18n.json"
45
46
" /abc/{prefixes}/*.json" | " /abc/def/xxx.json"
46
47
" {prefixes}/*.json" | " /abc/def/xxx.json"
47
48
" /abc/**/i18n_{locale}.json" | " /abc/def/i18n_pl-PL.json"
@@ -135,11 +136,12 @@ class I18nPathPatternSpec extends Specification {
135
136
when :
136
137
I18nPathGroups matched = matchGroups(pattern, input)
137
138
then :
138
- matched. path() == I18nPath . of(path)
139
+ matched. path() == (path == null ? null : I18nPath . of(path) )
139
140
where :
140
141
pattern | input || path
141
142
" **/i18n-{prefix}.yml" | " /abc/i18n-homepage.yml" || " homepage"
142
143
" /i18n/{prefix}.yml" | " /i18n/glossary.yml" || " glossary"
144
+ " com/i18n/{prefixes}/i18n.yml" | " com/i18n/i18n.yml" || null
143
145
" com/i18n/{prefixes}/i18n.yml" | " com/i18n/abc/def/i18n.yml" || " abc.def"
144
146
" com/i18n/{prefixes}/i18n-{prefix}.yml" | " com/i18n/abc/def/i18n-base.yml" || " abc.def.base"
145
147
" com/i18n/{prefixes}/xxx/i18n.yml" | " com/i18n/abc/def/xxx/i18n.yml" || " abc.def"
You can’t perform that action at this time.
0 commit comments