Skip to content

Commit 01ae37b

Browse files
committed
support ftp+rsync in extract_path
1 parent 24899d5 commit 01ae37b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/functions/extract_path.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ namespace duckdb
2626
// Explanation:
2727
// ^ - Start of the string
2828
// (?: - Non-capturing group for the protocol and domain part
29-
// (?:https?:\/\/)? - Optional http:// or https://
29+
// (?:(?:ftp|https?|rsync):\/\/)? - Optional ftp://, http://, https://, or rsync://
3030
// (?:[^\/\s]+) - Domain name (any characters except '/' or whitespace)
3131
// )
3232
// (\/[^?#]*) - Capturing group for the path (starts with '/', followed by any characters except '?' or '#')
33-
std::regex path_regex (R"(^(?:(?:https?:\/\/)?(?:[^\/\s]+))(\/[^?#]*))");
33+
std::regex path_regex (R"(^(?:(?:(?:ftp|https?|rsync):\/\/)?(?:[^\/\s]+))(\/[^?#]*))");
3434
std::smatch path_match;
3535

3636
// Use regex_search to find the path component in the input string

test/sql/extract_path.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@ query I
5353
SELECT extract_path('example.com.ac:443/path/path');
5454
----
5555
/path/path
56+
57+
query I
58+
SELECT extract_path('ftp://ftp.exmple.com/path/path');
59+
----
60+
/path/path
61+
62+
query I
63+
SELECT extract_path('rsync://rpki.exmple.com/path/path');
64+
----
65+
/path/path

0 commit comments

Comments
 (0)