Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URL constructor when called with base argument #35

Closed
wants to merge 1 commit into from

Conversation

Arshia001
Copy link
Contributor

This PR fixes constructing a URL with a base. Since Url::options is meant to be used with fluent syntax, calling options.base_url without storing the result has no effect.

Confusingly, ParseOptions implements Copy, which prevented this error from being caught by the compiler.

let base = base.as_ref().and_then(|base| Url::parse(base).ok());
options.base_url(base.as_ref());
let url = options.parse(&input).map_err(|error| Error::new(&error.to_string(), None))?;
let base = base.as_ref().and_then(|base| url::Url::parse(base).ok());
Copy link
Owner

Choose a reason for hiding this comment

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

You can directly use Url::parse here, without fully qualifying the path.

options.base_url(base.as_ref());
let url = options.parse(&input).map_err(|error| Error::new(&error.to_string(), None))?;
let base = base.as_ref().and_then(|base| url::Url::parse(base).ok());
let url = url::Url::options()
Copy link
Owner

Choose a reason for hiding this comment

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

Same as above, but with Url::options.

@Redfire75369
Copy link
Owner

Redfire75369 commented Nov 2, 2023

Thanks for the fix, I'll make a PR upstream to address this problem. Edit: servo/rust-url#876
Don't worry about the CI failure, I just need to update mozjs for that.

@Redfire75369
Copy link
Owner

Fixed in 38c4177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants