Skip to content

Commit 7a3d309

Browse files
committed
is_prefix, is_subdir: normalize
1 parent 5ee23c3 commit 7a3d309

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/lexical.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,12 @@ bool
131131
fs_is_prefix(std::string_view prefix, std::string_view path)
132132
{
133133
// Lexicographically, is prefix a prefix of path.
134-
// Does not normalize, canonicalize, or walk up the directory tree.
135-
// "." or ".." or mix of absolute and relative paths give ambiguous results
136134

137135
if(prefix.empty() || path.empty())
138136
return false;
139137

140-
std::string const pr = fs_drop_slash(prefix);
141-
std::string const p = fs_drop_slash(path);
138+
std::string const pr = fs_normal(prefix);
139+
std::string const p = fs_normal(path);
142140

143141
if (pr == p)
144142
return true;
@@ -159,14 +157,12 @@ bool
159157
fs_is_subdir(std::string_view subdir, std::string_view dir)
160158
{
161159
// Lexicographically, is subdir a subdirectory of dir.
162-
// Does not normalize, canonicalize, or walk up the directory tree.
163-
// "." or ".." give ambiguous results
164160

165161
if(subdir.empty() || dir.empty())
166162
return false;
167163

168-
std::string const s = fs_drop_slash(subdir);
169-
std::string const d = fs_drop_slash(dir);
164+
std::string const s = fs_normal(subdir);
165+
std::string const d = fs_normal(dir);
170166

171167
if(s == d)
172168
return false;

0 commit comments

Comments
 (0)