@@ -93,7 +93,7 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
9393 throw new XPathException (this , ErrorCodes .FODC0002 , "No URI is supplied and default resource collection is absent." );
9494 }
9595 } else {
96- final List <String > resultUris = new LinkedList <String >();
96+ final List <String > resultUris = new LinkedList <>();
9797
9898 final String uriWithQueryString = args [0 ].toString ();
9999 final int queryStringIndex = uriWithQueryString .indexOf ('?' );
@@ -174,19 +174,21 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
174174
175175 private static Map <String , String > parseQueryString (final String uri ) {
176176 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+ }
185189 } else {
186- map .put (keyValuePair .substring ( 0 , equalIndex ). trim (), "" );
190+ map .put (keyValuePair .trim (), "" );
187191 }
188- } else {
189- map .put (keyValuePair .trim (), "" );
190192 }
191193 }
192194 }
@@ -199,11 +201,11 @@ private void checkQueryStringMap(final Map<String, String> queryStringMap) throw
199201 final String key = queryStringEntry .getKey ();
200202 final String value = queryStringEntry .getValue ();
201203 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 ))) {
203205 throw new XPathException (this , ErrorCodes .FODC0004 , String .format ("Invalid query-string value \" %s\" ." , queryStringEntry ));
204206 }
205207 } 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 ))) {
207209 throw new XPathException (this , ErrorCodes .FODC0004 , String .format ("Invalid query-string value \" %s\" ." , queryStringEntry ));
208210 }
209211 } else if (!key .equals (KEY_MATCH )) {
0 commit comments