Skip to content

Commit c920736

Browse files
committed
regex
1 parent 4d7e247 commit c920736

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/vortex_scan.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#else
1717
#error "No filesystem support available"
1818
#endif
19+
#include <regex>
1920

2021
#include "vortex_common.hpp"
2122
#include "expr/expr.hpp"
@@ -158,7 +159,14 @@ static void ExtractVortexSchema(const vx_dtype *file_dtype, vector<LogicalType>
158159
}
159160
}
160161

162+
const std::regex schema_prefix = std::regex("^[^/]*:\\/\\/.*$");
163+
161164
std::string EnsureFileProtocol(const std::string &path) {
165+
// Check if the path has a schema, if not prepend the file:// schema
166+
if (std::regex_match(path, schema_prefix)) {
167+
return path;
168+
}
169+
162170
auto absolute_path = path;
163171
const std::string prefix = "file://";
164172

@@ -171,10 +179,6 @@ std::string EnsureFileProtocol(const std::string &path) {
171179
}
172180
}
173181

174-
// Check if the string already starts with "file://"
175-
if (absolute_path.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), absolute_path.begin())) {
176-
return absolute_path;
177-
}
178182
return prefix + absolute_path;
179183
}
180184

0 commit comments

Comments
 (0)