mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-15 06:26:07 +00:00
Fix routes.zig Windows paths
Use `std.zig.pstringEscape` to correctly escape a string for setting as a Zig string. This should catch any potential issue with escaping strings.
This commit is contained in:
parent
4010383ff7
commit
e004eb3d86
@ -437,9 +437,12 @@ fn parseFunction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const full_path = try std.fs.path.join(self.allocator, &[_][]const u8{ "src", "app", "views", path });
|
||||||
|
defer self.allocator.free(full_path);
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.name = function_name,
|
.name = function_name,
|
||||||
.path = try std.fs.path.join(self.allocator, &[_][]const u8{ "src", "app", "views", path }),
|
.path = try escapeString(self.allocator, full_path),
|
||||||
.args = try self.allocator.dupe(Arg, args.items),
|
.args = try self.allocator.dupe(Arg, args.items),
|
||||||
.source = try self.allocator.dupe(u8, source),
|
.source = try self.allocator.dupe(u8, source),
|
||||||
.params = std.ArrayList([]const u8).init(self.allocator),
|
.params = std.ArrayList([]const u8).init(self.allocator),
|
||||||
@ -484,3 +487,13 @@ fn isActionFunctionName(name: []const u8) bool {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn escapeString(allocator: std.mem.Allocator, input: []const u8) ![]const u8 {
|
||||||
|
var buf = std.ArrayList(u8).init(allocator);
|
||||||
|
defer buf.deinit();
|
||||||
|
const writer = buf.writer();
|
||||||
|
|
||||||
|
try std.zig.stringEscape(input, "", .{}, writer);
|
||||||
|
|
||||||
|
return try allocator.dupe(u8, buf.items);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user