Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion std/src/std/net/http/server.inko
Original file line number Diff line number Diff line change
Expand Up @@ -3247,7 +3247,7 @@ type pub inline Directory {
fn redirect_to_parent(components: array.Slice[Slice[String]]) -> Response {
let dir = match components.split_last {
case Some((_, head)) -> {
UriPath.root.join(UriPath.from_slice(head)).with_trailing_separator
UriPath.root.join(UriPath.from_iter(head.iter)).with_trailing_separator
}
case _ -> UriPath.root
}
Expand Down
9 changes: 4 additions & 5 deletions std/src/std/uri.inko
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# When normalizing an international URI, multi-byte character sequences are
# _not_ converted to their lowercase equivalent due to this being locale
# specific.
import std.array (Slice as ArraySlice)
import std.bytes (Bytes, Slice, ToByteArray)
import std.bytes.parsers (
LOWER_A, UPPER_A, alpha?, digit?, hex?, lower?, lower_hex_char?, to_lower,
Expand Down Expand Up @@ -1173,7 +1172,7 @@ type pub inline Path {
}
}

# Returns a new `Path` from a `std.array.Slice` of percent-decoded path
# Returns a new `Path` from a `std.iter.Iter` of percent-decoded path
# components.
#
# This method is useful when you've previously parsed a `Path` using e.g.
Expand All @@ -1187,13 +1186,13 @@ type pub inline Path {
# let path = Path.new('a/b/%20/c').get
# let comp = path.components.to_array
#
# Path.from_slice(comp.slice(0, comp.size - 1)) # => Path('a/b/%20')
# Path.from_slice(comp.slice(0, comp.size - 1).iter) # => Path('a/b/%20')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, let’s pretend I actually changed it here too — will fix

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@winterqt I think you meant this when you said you'd fix this so feel free to ignore, but Path.from_slice here should be changed to Path.from_iter 😄

@yorickpeterse yorickpeterse Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@winterqt Would you like me to finish this PR, or do you want to take care of it yourself?

# ```
fn pub static from_slice[B: Bytes](slice: ArraySlice[B]) -> Path {
fn pub static from_iter[B: Bytes, I: Iter[B]](iter: move I) -> Path {
let buf = ByteArray.new
let mut len = 0

for val in slice {
for val in iter {
if len > 0 { buf.push(SLS) }

encode_into(val, buf, tables.ENCODE_PATH)
Expand Down
10 changes: 5 additions & 5 deletions std/test/std/test_uri.inko
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ fn pub tests(t: mut Tests) {
t.equal(Path.new('/%ff'), Option.Some(Path('/%ff')))
})

t.test('Path.from_slice', fn (t) {
t.equal(Path.from_slice(([] as Array[String]).to_slice), Path(''))
t.equal(Path.from_slice(['a'].to_slice), Path('a'))
t.equal(Path.from_slice(['a', 'b'].to_slice), Path('a/b'))
t.equal(Path.from_slice(['a', 'b', '..', 'c'].to_slice), Path('a/b/../c'))
t.test('Path.from_iter', fn (t) {
t.equal(Path.from_iter(([] as Array[String]).iter), Path(''))
t.equal(Path.from_iter(['a'].iter), Path('a'))
t.equal(Path.from_iter(['a', 'b'].iter), Path('a/b'))
t.equal(Path.from_iter(['a', 'b', '..', 'c'].iter), Path('a/b/../c'))
})

t.test('Path.join', fn (t) {
Expand Down