Skip to content

Commit

Permalink
Normalize REPOSITORY_URL (#2206)
Browse files Browse the repository at this point in the history
* Normalize repo url

Signed-off-by: Austin Liu <austin362667@gmail.com>

* Remove redundant `normalize_url()`

Signed-off-by: Austin Liu <austin362667@gmail.com>

* Simplify pattern matching

Signed-off-by: Austin Liu <austin362667@gmail.com>

* Refactor for simplification

Signed-off-by: Austin Liu <austin362667@gmail.com>

---------

Signed-off-by: Austin Liu <austin362667@gmail.com>
  • Loading branch information
austin362667 authored Sep 2, 2024
1 parent 5fe6435 commit 9a4c8b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub struct PublishOpt {
}

impl PublishOpt {
const DEFAULT_REPOSITORY_URL: &'static str = "https://upload.pypi.org/legacy/";
const TEST_REPOSITORY_URL: &'static str = "https://test.pypi.org/legacy/";
const DEFAULT_REPOSITORY_URL: &'static str = "https://upload.pypi.org/legacy";
const TEST_REPOSITORY_URL: &'static str = "https://test.pypi.org/legacy";

/// Set to non interactive mode if we're running on CI
pub fn non_interactive_on_ci(&mut self) {
Expand Down Expand Up @@ -316,7 +316,8 @@ fn complete_registry(opt: &PublishOpt) -> Result<Registry> {
let pypirc = load_pypirc();
let (registry_name, registry_url) = if let Some(repository_url) = opt.repository_url.as_deref()
{
let name = match repository_url {
// to normalize URLs by removing trailing slashes
let name = match repository_url.trim_end_matches('/') {
PublishOpt::DEFAULT_REPOSITORY_URL => Some("pypi"),
PublishOpt::TEST_REPOSITORY_URL => Some("testpypi"),
_ => None,
Expand Down

0 comments on commit 9a4c8b7

Please sign in to comment.