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

feat: add url feature #190

Merged
merged 2 commits into from
Aug 8, 2024
Merged

feat: add url feature #190

merged 2 commits into from
Aug 8, 2024

Conversation

foolishell
Copy link
Contributor

for issue: #189

I think it's best to use https://example.com/ as a fixed URL.


impl Dummy<Faker> for Url {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self {
let path: String = Faker.fake_with_rng(rng);
Copy link
Owner

Choose a reason for hiding this comment

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

are arbitrary string can be a valid path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is. If path is [a-zA-Z], it must be valid.

However, I think it's better to define paths as const.
FIXED: c736536

impl Dummy<Faker> for Url {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self {
let path: String = Faker.fake_with_rng(rng);
Url::parse(&format!("{FQDN}/{path}")).unwrap()
Copy link
Owner

Choose a reason for hiding this comment

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

the unwrap may panic due to path is not valid, I think we should make it alway valid path?

@foolishell
Copy link
Contributor Author

foolishell commented Aug 6, 2024

#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn valid_urls_generated() {
        for _ in 0..10 {
            let url = Faker.fake::<Url>();
            println!("{}", url);
        }
    }
}

I tried this test. it worked.

@foolishell foolishell requested a review from cksac August 6, 2024 10:06
@foolishell
Copy link
Contributor Author

@cksac
Hi, could you review again?
And I have no idea why Clippy is failed. Could you help it?

@cksac
Copy link
Owner

cksac commented Aug 8, 2024

LGTM. will fix the Clippy warning later

@cksac cksac merged commit 93c02c0 into cksac:master Aug 8, 2024
4 of 5 checks passed
@foolishell
Copy link
Contributor Author

Thank you @cksac !
Please release the new version at your earliest convenience.

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