{"id":19577943,"url":"https://github.com/mihaigalos/url-parse","last_synced_at":"2025-04-27T06:33:07.407Z","repository":{"id":42516391,"uuid":"506713275","full_name":"mihaigalos/url-parse","owner":"mihaigalos","description":"🔗 A library for parsing URLs.","archived":false,"fork":false,"pushed_at":"2024-03-23T04:56:51.000Z","size":174,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-23T05:39:27.477Z","etag":null,"topics":["parser","rust","url"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mihaigalos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-23T16:27:04.000Z","updated_at":"2024-05-05T12:27:42.753Z","dependencies_parsed_at":"2023-02-15T07:01:52.623Z","dependency_job_id":"7a5c360f-ba0e-45b4-bfcb-ed713fd6fe00","html_url":"https://github.com/mihaigalos/url-parse","commit_stats":{"total_commits":214,"total_committers":4,"mean_commits":53.5,"dds":0.07009345794392519,"last_synced_commit":"7cac75c6c7925c1c493da85c1b3721ece7b501e5"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaigalos%2Furl-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaigalos%2Furl-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaigalos%2Furl-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mihaigalos%2Furl-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mihaigalos","download_url":"https://codeload.github.com/mihaigalos/url-parse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224062767,"owners_count":17249291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser","rust","url"],"created_at":"2024-11-11T07:08:56.894Z","updated_at":"2024-11-11T07:08:57.505Z","avatar_url":"https://github.com/mihaigalos.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# url-parse\n\n[![CI](https://github.com/mihaigalos/url-parse/actions/workflows/ci.yaml/badge.svg)](https://github.com/mihaigalos/url-parse/actions/workflows/ci.yaml)\n[![CD](https://github.com/mihaigalos/url-parse/actions/workflows/cd.yaml/badge.svg)](https://github.com/mihaigalos/url-parse/actions/workflows/cd.yaml)\n[![Security Audit](https://github.com/mihaigalos/url-parse/actions/workflows/audit.yaml/badge.svg)](https://github.com/mihaigalos/url-parse/actions/workflows/audit.yaml)\n[![codecov](https://codecov.io/gh/mihaigalos/url-parse/branch/main/graph/badge.svg?token=crukaI8Gmf)](https://codecov.io/gh/mihaigalos/url-parse)\n[![crates.io](https://img.shields.io/crates/d/url-parse.svg)](https://crates.io/crates/url-parse)\n[![Documentation](https://docs.rs/url-parse/badge.svg)](https://docs.rs/url-parse)\n\nA library for parsing URLs.\n\n## Why?\n\n`url-parse` provides some schemes unavailable in other url parsing crates (i.e. `sftp`, `ssh`, `s3`) and enables the user to specify custom schemes before parsing.\n\n## Usage\n\n### Basic\n\nCreate a new parser object with `Parser::new()`. You can then use `parser.parse(url)` which will return a public `Url` parsed structure back.\n\nIts fields are then directly accessible:\n\n```rust\nlet input = \"https://user:pass@www.example.co.uk:443/blog/article/search?docid=720\u0026hl=en#dayone\";\nlet result = Parser::new(None).parse(input).unwrap();\nassert_eq!(\n    result,\n    Url {\n        scheme: Some(\"https\".to_string()),\n        user_pass: (Some(\"user\".to_string()), Some(\"pass\".to_string())),\n        subdomain: Some(\"www\".to_string()),\n        domain: Some(\"example.co\".to_string()),\n        top_level_domain: Some(\"uk\".to_string()),\n        port: Some(443),\n        path: Some(vec![\n            \"blog\".to_string(),\n            \"article\".to_string(),\n            \"search\".to_string(),\n        ]),\n        query: Some(\"docid=720\u0026hl=en#dayone\".to_string()),\n        anchor: Some(\"dayone\".to_string()),\n    }\n)\n```\n\n### Custom schemes\n\nPassing a `Some(HashMap)` to `Parser::new()` can be used to create custom schemes.\n\nThe hashmap is a key,value pair representing the scheme name (key) to a port and description mapping (value).\n\n```rust\nlet input = \"myschema://user:pass@example.co.uk/path/to/file.txt\";\nlet mut myport_mappings = HashMap::new();\nmyport_mappings.insert(\"myschema\", (8888, \"My custom schema\"));\nlet result = Parser::new(Some(myport_mappings)).parse(input).unwrap();\nassert_eq!(\n    result,\n    Url {\n        scheme: Some(\"myschema\".to_string()),\n        user_pass: (Some(\"user\".to_string()), Some(\"pass\".to_string())),\n        subdomain: Some(\"www\".to_string()),\n        domain: Some(\"example.co\".to_string()),\n        top_level_domain: Some(\"uk\".to_string()),\n        port: Some(8888),\n        path: Some(vec![\n            \"path\".to_string(),\n            \"to\".to_string(),\n            \"file.txt\".to_string(),\n        ]),\n        query: None,\n        anchor: None,\n    }\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihaigalos%2Furl-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmihaigalos%2Furl-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmihaigalos%2Furl-parse/lists"}