feat!: introduce Path as a subset of Url to enforce type safety (#3361)

This commit is contained in:
sxyazi 2025-11-24 14:14:52 +08:00
parent 76fe6d7244
commit 643697cd3f
No known key found for this signature in database
2 changed files with 4 additions and 0 deletions

View file

@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Rename `name` to `url` for open, fetchers, spotters, preloaders, previewers, filetype, and `globs` icon rules to support virtual file system ([#3034])
- Rename `mime` fetcher to `mime.local`, and introduce `mime.dir` fetcher to support folder MIME types ([#3222])
- Remove `$0` parameter in opener rules to make the `open` command work under empty directories ([#3226])
- Return `Path` instead of `Url` from `Url:strip_prefix()` to enforce type safety ([#3361])
- Use `body` instead of the term `content` in confirmations ([#2921])
- Use `u16` instead of `u32` as the type of `max_width` and `max_height` options to avoid memory exhaustion ([#3313])
- Implement `__pairs` metamethod instead of `__index` for the callback argument of the `@yank` DDS event ([#2997])

View file

@ -115,6 +115,9 @@ impl UserData for Path {
cached_field!(fields, stem, |lua, me| {
me.stem().map(|s| lua.create_string(s.encoded_bytes())).transpose()
});
fields.add_field_method_get("is_absolute", |_, me| Ok(me.is_absolute()));
fields.add_field_method_get("has_root", |_, me| Ok(me.has_root()));
}
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {