mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
Ignore whitespaces surrounding a shared worktree's URL
This commit is contained in:
parent
0f399c6a01
commit
ccff27a157
1 changed files with 5 additions and 1 deletions
|
@ -288,7 +288,7 @@ pub fn encode_worktree_url(id: u64, access_token: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode_worktree_url(url: &str) -> Option<(u64, String)> {
|
pub fn decode_worktree_url(url: &str) -> Option<(u64, String)> {
|
||||||
let path = url.strip_prefix(WORKTREE_URL_PREFIX)?;
|
let path = url.trim().strip_prefix(WORKTREE_URL_PREFIX)?;
|
||||||
let mut parts = path.split('/');
|
let mut parts = path.split('/');
|
||||||
let id = parts.next()?.parse::<u64>().ok()?;
|
let id = parts.next()?.parse::<u64>().ok()?;
|
||||||
let access_token = parts.next()?;
|
let access_token = parts.next()?;
|
||||||
|
@ -309,5 +309,9 @@ const LOGIN_RESPONSE: &'static str = "
|
||||||
fn test_encode_and_decode_worktree_url() {
|
fn test_encode_and_decode_worktree_url() {
|
||||||
let url = encode_worktree_url(5, "deadbeef");
|
let url = encode_worktree_url(5, "deadbeef");
|
||||||
assert_eq!(decode_worktree_url(&url), Some((5, "deadbeef".to_string())));
|
assert_eq!(decode_worktree_url(&url), Some((5, "deadbeef".to_string())));
|
||||||
|
assert_eq!(
|
||||||
|
decode_worktree_url(&format!("\n {}\t", url)),
|
||||||
|
Some((5, "deadbeef".to_string()))
|
||||||
|
);
|
||||||
assert_eq!(decode_worktree_url("not://the-right-format"), None);
|
assert_eq!(decode_worktree_url("not://the-right-format"), None);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue