fix: account for URL covariance in Url:join() (#3514)

This commit is contained in:
三咲雅 misaki masa 2026-01-06 11:55:48 +08:00 committed by GitHub
parent 3c39a326ab
commit c9327ca851
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
## [Unreleased] ## [Unreleased]
### Fixed
- Account for URL covariance in `Url:join()` ([#3514])
## [v26.1.4] ## [v26.1.4]
### Added ### Added
@ -1583,3 +1587,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
[#3477]: https://github.com/sxyazi/yazi/pull/3477 [#3477]: https://github.com/sxyazi/yazi/pull/3477
[#3482]: https://github.com/sxyazi/yazi/pull/3482 [#3482]: https://github.com/sxyazi/yazi/pull/3482
[#3494]: https://github.com/sxyazi/yazi/pull/3494 [#3494]: https://github.com/sxyazi/yazi/pull/3494
[#3514]: https://github.com/sxyazi/yazi/pull/3514

View file

@ -2,7 +2,7 @@ use std::ops::Deref;
use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, UserData, UserDataFields, UserDataMethods, UserDataRef, Value}; use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, UserData, UserDataFields, UserDataMethods, UserDataRef, Value};
use yazi_fs::{FsHash64, FsHash128, FsUrl}; use yazi_fs::{FsHash64, FsHash128, FsUrl};
use yazi_shared::{path::{PathLike, StripPrefixError}, scheme::SchemeCow, strand::{StrandLike, ToStrand}, url::{AsUrl, UrlCow, UrlLike}}; use yazi_shared::{path::{PathLike, StripPrefixError}, scheme::{SchemeCow, SchemeLike}, strand::{StrandLike, ToStrand}, url::{AsUrl, UrlCow, UrlLike}};
use crate::{Path, Scheme, cached_field, deprecate}; use crate::{Path, Scheme, cached_field, deprecate};
@ -121,7 +121,7 @@ impl Url {
Value::String(s) => { Value::String(s) => {
let b = s.as_bytes(); let b = s.as_bytes();
let (scheme, path) = SchemeCow::parse(&b)?; let (scheme, path) = SchemeCow::parse(&b)?;
if scheme == self.scheme() { if scheme.covariant(self.scheme()) {
Self::new(self.try_join(path).into_lua_err()?).into_lua(lua) Self::new(self.try_join(path).into_lua_err()?).into_lua(lua)
} else { } else {
Self::new(UrlCow::try_from((scheme, path))?).into_lua(lua) Self::new(UrlCow::try_from((scheme, path))?).into_lua(lua)
@ -129,7 +129,7 @@ impl Url {
} }
Value::UserData(ref ud) => { Value::UserData(ref ud) => {
let url = ud.borrow::<Self>()?; let url = ud.borrow::<Self>()?;
if url.scheme() == self.scheme() { if url.scheme().covariant(self.scheme()) {
Self::new(self.try_join(url.loc()).into_lua_err()?).into_lua(lua) Self::new(self.try_join(url.loc()).into_lua_err()?).into_lua(lua)
} else { } else {
Ok(other) Ok(other)