hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit fccce047c9f0207b1905aea177948e7d6ce5d836
parent 36c9b5c9dbaca194d8fbd5d1358c72d325fcbfcf
Author: Conrad Hoffmann <ch@bitfehler.net>
Date:   Tue, 16 Jul 2024 12:12:16 +0200

net/uri: fix silly usage of wantrune()

This is a follow-up to my previous fix. I now realized that using
`wantrune()` like I did here is silly. If I understand correctly,
`wantrune()` expresses that there should be a next rune or the URI is
invalid, but this is not the case here. So stick to `strings::next()`
and handle `done` instead of `invalid` (not much sense in handling an
event called `invalid` and continue parsing...).

Signed-off-by: Conrad Hoffmann <ch@bitfehler.net>

Diffstat:
Mnet/uri/parse.ha | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/uri/parse.ha b/net/uri/parse.ha @@ -40,7 +40,7 @@ export fn parse(in: str) (uri | invalid) = { switch (r) { case '/' => // Either "//"+authority+path-abempty or path-absolute - match (wantrune(&in)) { + match (strings::next(&in)) { case let r: rune => switch(r) { case '/' => @@ -68,7 +68,7 @@ export fn parse(in: str) (uri | invalid) = { strings::prev(&in); // return leading slash path = parse_path(&in, path_mode::ABSOLUTE)?; }; - case invalid => + case => // path-absolute (just '/') strings::prev(&in); // return leading slash path = parse_path(&in, path_mode::ABSOLUTE)?;