| 
49 | 49 |  */  | 
50 | 50 | public class Configuration {  | 
51 | 51 | 
 
  | 
52 |  | - private static final Pattern URL_PARAMETER =  | 
53 |  | - Pattern.compile("(/([^?]*))?(\\?(.+))*", Pattern.DOTALL);  | 
54 |  | - | 
55 | 52 |  // standard options  | 
56 | 53 |  private String user = null;  | 
57 | 54 |  private String password = null;  | 
@@ -533,25 +530,31 @@ private static Configuration parseInternal(String url, Properties properties)  | 
533 | 530 |  }  | 
534 | 531 | 
 
  | 
535 | 532 |  if (additionalParameters != null) {  | 
536 |  | - //noinspection Annotator  | 
537 |  | - Matcher matcher = URL_PARAMETER.matcher(additionalParameters);  | 
538 |  | - matcher.find();  | 
539 |  | - String database = matcher.group(2);  | 
540 |  | - if (database != null && !database.isEmpty()) {  | 
541 |  | - builder.database(database);  | 
542 |  | - }  | 
543 |  | - String urlParameters = matcher.group(4);  | 
544 |  | - if (urlParameters != null && !urlParameters.isEmpty()) {  | 
545 |  | - String[] parameters = urlParameters.split("&");  | 
546 |  | - for (String parameter : parameters) {  | 
547 |  | - int pos = parameter.indexOf('=');  | 
548 |  | - if (pos == -1) {  | 
549 |  | - properties.setProperty(parameter, "");  | 
550 |  | - } else {  | 
551 |  | - properties.setProperty(parameter.substring(0, pos), parameter.substring(pos + 1));  | 
 | 533 | + int optIndex = additionalParameters.indexOf("?");  | 
 | 534 | + String database;  | 
 | 535 | + if (optIndex < 0) {  | 
 | 536 | + database = (additionalParameters.length() > 1) ? additionalParameters.substring(1) : null;  | 
 | 537 | + } else {  | 
 | 538 | + if (optIndex == 0) {  | 
 | 539 | + database = null;  | 
 | 540 | + } else {  | 
 | 541 | + database = additionalParameters.substring(1, optIndex);  | 
 | 542 | + if (database.isEmpty()) database = null;  | 
 | 543 | + }  | 
 | 544 | + String urlParameters = additionalParameters.substring(optIndex + 1);  | 
 | 545 | + if (urlParameters != null && !urlParameters.isEmpty()) {  | 
 | 546 | + String[] parameters = urlParameters.split("&");  | 
 | 547 | + for (String parameter : parameters) {  | 
 | 548 | + int pos = parameter.indexOf('=');  | 
 | 549 | + if (pos == -1) {  | 
 | 550 | + properties.setProperty(parameter, "");  | 
 | 551 | + } else {  | 
 | 552 | + properties.setProperty(parameter.substring(0, pos), parameter.substring(pos + 1));  | 
 | 553 | + }  | 
552 | 554 |  }  | 
553 | 555 |  }  | 
554 | 556 |  }  | 
 | 557 | + builder.database(database);  | 
555 | 558 |  } else {  | 
556 | 559 |  builder.database(null);  | 
557 | 560 |  }  | 
 | 
0 commit comments