aboutsummaryrefslogblamecommitdiff
path: root/url.ha
blob: 784f602d10ad700bda1828ec3a16969fe378dbc9 (plain) (tree)
1
2
3
4
5
6
7


                                                                            


             
                                                  





                                                                     
// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>

use strings;
use net::uri;

// The result must be freed with strings::freeall;
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];
};