aboutsummaryrefslogtreecommitdiff
path: root/url.ha
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-15 01:16:39 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-15 01:16:39 +0800
commitcb2517bee240c592c07e77c1507877cf47ace553 (patch)
treeea316415dfb1f29684c80e108762e4a66c937fb4 /url.ha
parentAdd horrible patch needed to make net::uri work (diff)
downloadforge-cb2517bee240c592c07e77c1507877cf47ace553.tar.gz
forge-cb2517bee240c592c07e77c1507877cf47ace553.tar.zst
forge-cb2517bee240c592c07e77c1507877cf47ace553.zip
Separate paths into segments
Diffstat (limited to '')
-rw-r--r--url.ha15
1 files changed, 15 insertions, 0 deletions
diff --git a/url.ha b/url.ha
new file mode 100644
index 0000000..3d7862f
--- /dev/null
+++ b/url.ha
@@ -0,0 +1,15 @@
+use strings;
+use net::uri;
+
+fn segments_from_path(s: str) ([]str | nomem | net::uri::invalid) = {
+ let sp: []str = strings::split(s, "/")?;
+ for (let i = 1z; i < len(sp); i += 1)
+ sp[i - 1] = net::uri::percent_decode(sp[i])?;
+ return sp[.. len(sp) - 1];
+};
+
+fn free_segments(ss: []str) void = {
+ for (let s .. ss) {
+ free(s);
+ };
+};