@@ -93,7 +93,7 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
93
93
throw new XPathException (this , ErrorCodes .FODC0002 , "No URI is supplied and default resource collection is absent." );
94
94
}
95
95
} else {
96
- final List <String > resultUris = new LinkedList <String >();
96
+ final List <String > resultUris = new LinkedList <>();
97
97
98
98
final String uriWithQueryString = args [0 ].toString ();
99
99
final int queryStringIndex = uriWithQueryString .indexOf ('?' );
@@ -174,19 +174,21 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
174
174
175
175
private static Map <String , String > parseQueryString (final String uri ) {
176
176
final Map <String , String > map = new HashMap <>();
177
- final int questionMarkIndex = (uri == null ) ? -1 : uri .indexOf ('?' );
178
- if (questionMarkIndex >= 0 && questionMarkIndex + 1 < uri .length ()) {
179
- String [] keyValuePairs = uri .substring (questionMarkIndex + 1 ).split ("&" );
180
- for (String keyValuePair : keyValuePairs ) {
181
- int equalIndex = keyValuePair .indexOf ('=' );
182
- if (equalIndex >= 0 ) {
183
- if (equalIndex + 1 < uri .length ()) {
184
- map .put (keyValuePair .substring (0 , equalIndex ).trim (), keyValuePair .substring (equalIndex + 1 ).trim ());
177
+ if (uri != null ) {
178
+ final int questionMarkIndex = uri .indexOf ('?' );
179
+ if (questionMarkIndex >= 0 && questionMarkIndex + 1 < uri .length ()) {
180
+ String [] keyValuePairs = uri .substring (questionMarkIndex + 1 ).split ("&" );
181
+ for (String keyValuePair : keyValuePairs ) {
182
+ int equalIndex = keyValuePair .indexOf ('=' );
183
+ if (equalIndex >= 0 ) {
184
+ if (equalIndex + 1 < uri .length ()) {
185
+ map .put (keyValuePair .substring (0 , equalIndex ).trim (), keyValuePair .substring (equalIndex + 1 ).trim ());
186
+ } else {
187
+ map .put (keyValuePair .substring (0 , equalIndex ).trim (), "" );
188
+ }
185
189
} else {
186
- map .put (keyValuePair .substring ( 0 , equalIndex ). trim (), "" );
190
+ map .put (keyValuePair .trim (), "" );
187
191
}
188
- } else {
189
- map .put (keyValuePair .trim (), "" );
190
192
}
191
193
}
192
194
}
@@ -199,11 +201,11 @@ private void checkQueryStringMap(final Map<String, String> queryStringMap) throw
199
201
final String key = queryStringEntry .getKey ();
200
202
final String value = queryStringEntry .getValue ();
201
203
if (key .equals (KEY_CONTENT_TYPE )) {
202
- if (! Arrays .stream (VALUE_CONTENT_TYPES ).anyMatch (contentTypeValue -> contentTypeValue .equals (value ))) {
204
+ if (Arrays .stream (VALUE_CONTENT_TYPES ).noneMatch (contentTypeValue -> contentTypeValue .equals (value ))) {
203
205
throw new XPathException (this , ErrorCodes .FODC0004 , String .format ("Invalid query-string value \" %s\" ." , queryStringEntry ));
204
206
}
205
207
} else if (key .equals (KEY_STABLE )) {
206
- if (! Arrays .stream (VALUE_STABLES ).anyMatch (stableValue -> stableValue .equals (value ))) {
208
+ if (Arrays .stream (VALUE_STABLES ).noneMatch (stableValue -> stableValue .equals (value ))) {
207
209
throw new XPathException (this , ErrorCodes .FODC0004 , String .format ("Invalid query-string value \" %s\" ." , queryStringEntry ));
208
210
}
209
211
} else if (!key .equals (KEY_MATCH )) {
0 commit comments