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

Simple fix to handle trailing slashs by parsing the server address. #979

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions atuin-client/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ pub async fn register(
map.insert("email", email);
map.insert("password", password);

let url = format!("{address}/user/{username}");
let base = Url::parse(address)?;
let url = base.join(format!("/user/{username}").as_str())?;
let resp = reqwest::get(url).await?;

if resp.status().is_success() {
bail!("username already in use");
}

let url = format!("{address}/register");
let url = base.join("/register")?;
let client = reqwest::Client::new();
let resp = client
.post(url)
Expand All @@ -69,7 +70,8 @@ pub async fn register(
}

pub async fn login(address: &str, req: LoginRequest) -> Result<LoginResponse> {
let url = format!("{address}/login");
let base = Url::parse(address)?;
let url = base.join("/login")?;
let client = reqwest::Client::new();

let resp = client
Expand Down