| ... | ... | @@ -3939,15 +3939,11 @@ pub fn importFile( |
| 3939 | 3939 | defer gpa.free(resolved_root_path); |
| 3940 | 3940 | |
| 3941 | 3941 | const sub_file_path = p: { |
| 3942 | | if (mem.startsWith(u8, resolved_path, resolved_root_path)) { |
| 3943 | | // +1 for the directory separator here. |
| 3944 | | break :p try gpa.dupe(u8, resolved_path[resolved_root_path.len + 1 ..]); |
| 3945 | | } |
| 3946 | | if (mem.eql(u8, resolved_root_path, ".") and |
| 3947 | | !isUpDir(resolved_path) and |
| 3948 | | !std.fs.path.isAbsolute(resolved_path)) |
| 3949 | | { |
| 3950 | | break :p try gpa.dupe(u8, resolved_path); |
| 3942 | const relative = try std.fs.path.relative(gpa, resolved_root_path, resolved_path); |
| 3943 | errdefer gpa.free(relative); |
| 3944 | |
| 3945 | if (!isUpDir(relative) and !std.fs.path.isAbsolute(relative)) { |
| 3946 | break :p relative; |
| 3951 | 3947 | } |
| 3952 | 3948 | return error.ImportOutsideModulePath; |
| 3953 | 3949 | }; |
| ... | ... | @@ -4038,15 +4034,11 @@ pub fn embedFile( |
| 4038 | 4034 | defer gpa.free(resolved_root_path); |
| 4039 | 4035 | |
| 4040 | 4036 | const sub_file_path = p: { |
| 4041 | | if (mem.startsWith(u8, resolved_path, resolved_root_path)) { |
| 4042 | | // +1 for the directory separator here. |
| 4043 | | break :p try gpa.dupe(u8, resolved_path[resolved_root_path.len + 1 ..]); |
| 4044 | | } |
| 4045 | | if (mem.eql(u8, resolved_root_path, ".") and |
| 4046 | | !isUpDir(resolved_path) and |
| 4047 | | !std.fs.path.isAbsolute(resolved_path)) |
| 4048 | | { |
| 4049 | | break :p try gpa.dupe(u8, resolved_path); |
| 4037 | const relative = try std.fs.path.relative(gpa, resolved_root_path, resolved_path); |
| 4038 | errdefer gpa.free(relative); |
| 4039 | |
| 4040 | if (!isUpDir(relative) and !std.fs.path.isAbsolute(relative)) { |
| 4041 | break :p relative; |
| 4050 | 4042 | } |
| 4051 | 4043 | return error.ImportOutsideModulePath; |
| 4052 | 4044 | }; |