hare

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

commit dd5d3948328cd6ed1272a93b198242a839fb026c
parent 4bedb1b40107713cac6bc343b9a8599b60e9611a
Author: Alexey Yerin <yyp@disroot.org>
Date:   Fri, 14 Jan 2022 11:24:45 +0300

path::extension: accept a (str | *buffer)

To be in-line with other functions.

Signed-off-by: Alexey Yerin <yyp@disroot.org>

Diffstat:
Mpath/names.ha | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/path/names.ha b/path/names.ha @@ -92,7 +92,8 @@ export fn basename(path: (str | *buffer)) const str = { // extension("foo/example") => ("example", "") // extension("foo/example.txt") => ("example", ".txt") // extension("foo/example.tar.gz") => ("example", ".tar.gz") -export fn extension(p: str) (str, str) = { +export fn extension(p: (str | *buffer)) (str, str) = { + let p = getstring(p); if (p == "") { return ("", ""); };