Skip to content

Commit 22094a9

Browse files
committed
dbeaver/dbeaver#38710 simplified check
1 parent 7ff8d70 commit 22094a9

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConstants.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
public class LibSqlConstants {
2222

2323
public static final String CONNECTION_URL_EXAMPLES = "jdbc:dbeaver:libsql:<hostname>, libsql://<hostname>";
24-
public static final String CONNECTION_PROTOCOLS_REGEXP = "jdbc:dbeaver:libsql:(http(s)?://)?(libsql://)?|libsql://";
2524
public static final Pattern CONNECTION_URL_PATTERN =
26-
Pattern.compile("(" + CONNECTION_PROTOCOLS_REGEXP + ")[a-z0-9:.-]+");
25+
Pattern.compile("(jdbc:dbeaver:libsql:)?(libsql://)?[a-z0-9/:.-]+");
2726

2827
public static final int DRIVER_VERSION_MAJOR = 1;
2928
public static final int DRIVER_VERSION_MINOR = 0;

com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDriver.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ public Connection connect(String url, Properties info) throws SQLException {
4949
".\nExpected URL formats: " + LibSqlConstants.CONNECTION_URL_EXAMPLES);
5050
}
5151

52-
String targetUrl = url.replace("jdbc:dbeaver:libsql:", "");
53-
if (!targetUrl.startsWith("http")) {
54-
targetUrl = matcher.group(0)
55-
.replaceAll(LibSqlConstants.CONNECTION_PROTOCOLS_REGEXP, "https://");
52+
String targetUrl = url.replaceFirst("jdbc:dbeaver:libsql:", "");
53+
if (targetUrl.startsWith("libsql://")) {
54+
targetUrl = targetUrl.replaceFirst("libsql://", "https://");
5655
}
5756

5857
Map<String, Object> props = new LinkedHashMap<>();

0 commit comments

Comments
 (0)