| ... | ... | @@ -536,8 +536,8 @@ pub const URL = struct { |
| 536 | 536 | c = inputl.items[i]; |
| 537 | 537 | // 1. If state override is not given and buffer is a Windows drive letter, file-invalid-Windows-drive-letter-host validation error, set state to path state. |
| 538 | 538 | // > This is a (platform-independent) Windows drive letter quirk. buffer is not reset here and instead used in the path state. |
| 539 | | if (builtin.target.os.tag == .windows) { |
| 540 | | @compileError("TODO"); |
| 539 | if (state_override == null and isWindowsDriveLetter(buffer.items)) { |
| 540 | state = .path; |
| 541 | 541 | } |
| 542 | 542 | // 2. Otherwise, if buffer is the empty string, then: |
| 543 | 543 | else if (buffer.items.len == 0) { |
| ... | ... | @@ -631,10 +631,12 @@ pub const URL = struct { |
| 631 | 631 | // @panic("TODO"); |
| 632 | 632 | } |
| 633 | 633 | // 4. Otherwise, if buffer is not a single-dot URL path segment, then: |
| 634 | | else if (isSingleDotPathSeg(buffer.items)) { |
| 634 | else if (!isSingleDotPathSeg(buffer.items)) { |
| 635 | 635 | // 1. If url’s scheme is "file", url’s path is empty, and buffer is a Windows drive letter, then replace the second code point in buffer with U+003A (:). |
| 636 | 636 | // > This is a (platform-independent) Windows drive letter quirk. |
| 637 | | if (builtin.target.os.tag == .windows) @compileError("TODO"); |
| 637 | if (std.mem.eql(u8, scheme.items, "file") and path.items.len == 0 and isWindowsDriveLetter(buffer.items)) { |
| 638 | buffer.items[1] = ':'; |
| 639 | } |
| 638 | 640 | // 2. Append buffer to url’s path. |
| 639 | 641 | try path.appendSlice(buffer.items); |
| 640 | 642 | } |
| ... | ... | @@ -835,6 +837,14 @@ fn isSingleDotPathSeg(segment: []const u8) bool { |
| 835 | 837 | return false; |
| 836 | 838 | } |
| 837 | 839 | |
| 840 | /// https://url.spec.whatwg.org/#windows-drive-letter |
| 841 | fn isWindowsDriveLetter(buffer: []const u8) bool { |
| 842 | if (buffer.len != 2) return false; |
| 843 | if (!std.ascii.isAlphabetic(buffer[0])) return false; |
| 844 | if (!(buffer[1] == ':' or buffer[1] == '|')) return false; |
| 845 | return true; |
| 846 | } |
| 847 | |
| 838 | 848 | /// https://url.spec.whatwg.org/#concept-host-parser |
| 839 | 849 | fn parseHost(allocator: std.mem.Allocator, input: []u8, isOpaque: bool) !URL.Host { |
| 840 | 850 | // 1. If input starts with U+005B ([), then: |