aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig
index 6f68295..18c86d1 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -393,7 +393,7 @@ pub fn areKeySectionContentsValid(contents: []const u8) bool {
393 return true; 393 return true;
394} 394}
395 395
396pub fn findKeySection(line_it: *std.mem.SplitIterator(u8)) ?[]const u8 { 396pub fn findKeySection(line_it: *std.mem.SplitIterator(u8, .scalar)) ?[]const u8 {
397 while (true) { 397 while (true) {
398 const opening_line = line_it.next() orelse return null; 398 const opening_line = line_it.next() orelse return null;
399 if (!isKeySectionBarrier(opening_line, true)) continue; 399 if (!isKeySectionBarrier(opening_line, true)) continue;
@@ -409,12 +409,12 @@ pub fn findKeySection(line_it: *std.mem.SplitIterator(u8)) ?[]const u8 {
409} 409}
410 410
411pub fn parseDecoratedJwt(contents: []const u8) []const u8 { 411pub fn parseDecoratedJwt(contents: []const u8) []const u8 {
412 var line_it = mem.split(u8, contents, "\n"); 412 var line_it = mem.splitScalar(u8, contents, '\n');
413 return findKeySection(&line_it) orelse return contents; 413 return findKeySection(&line_it) orelse return contents;
414} 414}
415 415
416pub fn parseDecoratedNkey(contents: []const u8) NoNkeySeedFoundError!SeedKeyPair { 416pub fn parseDecoratedNkey(contents: []const u8) NoNkeySeedFoundError!SeedKeyPair {
417 var line_it = mem.split(u8, contents, "\n"); 417 var line_it = mem.splitScalar(u8, contents, '\n');
418 var seed: ?[]const u8 = null; 418 var seed: ?[]const u8 = null;
419 if (findKeySection(&line_it) != null) 419 if (findKeySection(&line_it) != null)
420 seed = findKeySection(&line_it); 420 seed = findKeySection(&line_it);
@@ -444,8 +444,8 @@ fn isValidCredsNkey(text: []const u8) bool {
444fn findNkey(text: []const u8) ?[]const u8 { 444fn findNkey(text: []const u8) ?[]const u8 {
445 var line_it = std.mem.split(u8, text, "\n"); 445 var line_it = std.mem.split(u8, text, "\n");
446 while (line_it.next()) |line| { 446 while (line_it.next()) |line| {
447 for (line) |c, i| { 447 for (line, 0..) |c, i| {
448 if (!ascii.isSpace(c)) { 448 if (!ascii.isWhitespace(c)) {
449 if (isValidCredsNkey(line[i..])) return line[i..]; 449 if (isValidCredsNkey(line[i..])) return line[i..];
450 break; 450 break;
451 } 451 }
@@ -554,7 +554,7 @@ test "different key types" {
554 554
555test "validation" { 555test "validation" {
556 const roles = @typeInfo(Role).Enum.fields; 556 const roles = @typeInfo(Role).Enum.fields;
557 inline for (roles) |field, i| { 557 inline for (roles, 0..) |field, i| {
558 const role = @field(Role, field.name); 558 const role = @field(Role, field.name);
559 const next_role = next: { 559 const next_role = next: {
560 const next_field_i = if (i == roles.len - 1) 0 else i + 1; 560 const next_field_i = if (i == roles.len - 1) 0 else i + 1;