Skip to content

Commit

Permalink
update: use path::absolute stable api
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed Jun 16, 2024
1 parent 18af438 commit 348fda9
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::{
borrow::{Borrow, Cow},
env,
fmt::Display,
hash::Hash,
hash::Hasher,
hash::{Hash, Hasher},
path,
str::FromStr,
};

Expand Down Expand Up @@ -221,21 +220,11 @@ impl UrlFrag {
Ok(url) => Ok(UrlFrag { url, frag }),
#[cfg(not(target_arch = "wasm32"))]
Err(url::ParseError::RelativeUrlWithoutBase) => {
// TODO(unstable): replace with `path::absolute` once it is stabilized
use std::path::Path;
let mut path = Path::new(u);
let tmp;
if !path.is_absolute() {
tmp = env::current_dir()
.map_err(|e| CompileError::ParseUrlError {
url: u.to_owned(),
src: e.into(),
})?
.join(path);
path = tmp.as_path();
}

let url = Url::from_file_path(path).map_err(|_| {
let p = path::absolute(u).map_err(|e| CompileError::ParseUrlError {
url: u.to_owned(),
src: e.into(),
})?;
let url = Url::from_file_path(p).map_err(|_| {
CompileError::Bug(format!("failed to convert {u} into url").into())
})?;
Ok(UrlFrag { url, frag })
Expand Down

0 comments on commit 348fda9

Please sign in to comment.