{"id":21586074,"url":"https://github.com/magiclen/url-prefix","last_synced_at":"2025-09-02T10:40:23.656Z","repository":{"id":57671271,"uuid":"152701688","full_name":"magiclen/url-prefix","owner":"magiclen","description":"A library for creating URL prefix strings.","archived":false,"fork":false,"pushed_at":"2023-09-11T02:24:19.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T17:55:20.330Z","etag":null,"topics":["rust"],"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/magiclen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-10-12T06:05:10.000Z","updated_at":"2021-10-16T03:43:32.000Z","dependencies_parsed_at":"2024-11-24T18:01:10.647Z","dependency_job_id":null,"html_url":"https://github.com/magiclen/url-prefix","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"5b6865e00ed3ade5d125ca8e59f43d02dbcb1153"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Furl-prefix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Furl-prefix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Furl-prefix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Furl-prefix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/url-prefix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801160,"owners_count":20998339,"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":["rust"],"created_at":"2024-11-24T15:12:35.984Z","updated_at":"2025-04-10T20:15:25.214Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","readme":"URL Prefix\n====================\n\n[![CI](https://github.com/magiclen/url-prefix/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/url-prefix/actions/workflows/ci.yml)\n\nThis crate can be used to create URL prefix strings by inputting a protocol, a domain, a port number and a path without additional parsing.\n\n## Why We Need This?\n\nSometimes our web applications are run on different protocols(HTTP/HTTPS) and domains. And it is boring to write some code like below to format a URL:\n\n```rust\nlet mut url_prefix = String::new();\nif is_https {\n    url_prefix.push_str(\"https://\");\n} else {\n    url_prefix.push_str(\"http://\");\n}\nurl_prefix.push_str(domain);\n\nif is_https \u0026\u0026 port != 443 || !is_https \u0026\u0026 port != 80 {\n    url_prefix.push_str(\":\");\n    url_prefix.push_str(\u0026port.to_string());\n}\n```\n\nInstead, we can easily use this crate to create URL prefix strings. For examples,\n\n```rust\nlet prefix = url_prefix::create_prefix(url_prefix::Protocol::HTTPS, \"magiclen.org\", None, None);\n\nassert_eq!(\"https://magiclen.org\", prefix);\n```\n\n```rust\nlet prefix = url_prefix::create_prefix(url_prefix::Protocol::HTTPS, \"magiclen.org\", Some(8100), Some(\"url-prefix\"));\n\nassert_eq!(\"https://magiclen.org:8100/url-prefix\", prefix);\n```\n\n## Crates.io\n\nhttps://crates.io/crates/url-prefix\n\n## Documentation\n\nhttps://docs.rs/url-prefix\n\n## License\n\n[MIT](LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Furl-prefix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Furl-prefix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Furl-prefix/lists"}