@@ -9,13 +9,23 @@ namespace duckdb
99 {
1010 // Extract the input from the arguments
1111 auto &input_vector = args.data [0 ];
12- auto input = input_vector. GetValue ( 0 ). ToString ( );
12+ auto result_data = FlatVector::GetData< string_t > (result );
1313
14- // Extract the path using the utility function
15- auto path = netquack::ExtractPath (input);
14+ for (idx_t i = 0 ; i < args.size (); i++)
15+ {
16+ auto input = input_vector.GetValue (i).ToString ();
1617
17- // Set the result
18- result.SetValue (0 , Value (path));
18+ try
19+ {
20+ // Extract the path using the utility function
21+ auto path = netquack::ExtractPath (input);
22+ result_data[i] = StringVector::AddString (result, path);
23+ }
24+ catch (const std::exception &e)
25+ {
26+ result_data[i] = " Error extracting path: " + std::string (e.what ());
27+ }
28+ };
1929 }
2030
2131 namespace netquack
@@ -26,11 +36,12 @@ namespace duckdb
2636 // Explanation:
2737 // ^ - Start of the string
2838 // (?: - Non-capturing group for the protocol and domain part
29- // (?:(?:ftp|https?|rsync):\/\/)? - Optional ftp://, http://, https://, or rsync://
30- // (?:[^\/\s]+) - Domain name (any characters except '/' or whitespace)
39+ // (?:(?:ftp|https?|rsync):\/\/)? - Optional protocol ( ftp://, http://, https://, or rsync://)
40+ // (?:[^\/\s]+) - Domain name or IP address (any characters except '/' or whitespace)
3141 // )
32- // (\/[^?#]*) - Capturing group for the path (starts with '/', followed by any characters except '?' or '#')
33- std::regex path_regex (R"( ^(?:(?:(?:ftp|https?|rsync):\/\/)?(?:[^\/\s]+))(\/[^?#]*))" );
42+ // (\/[^?#]*)? - Optional capturing group for the path (starts with '/', followed by any characters except '?' or '#')
43+ // - The '?' at the end makes the path component optional, allowing the regex to match URLs with or without a path
44+ std::regex path_regex (R"( ^(?:(?:(?:ftp|https?|rsync):\/\/)?(?:[^\/\s]+))(\/[^?#]*)?)" );
3445 std::smatch path_match;
3546
3647 // Use regex_search to find the path component in the input string
0 commit comments