Fix Git permalinks not being URL-escaped (#39895)

Closes #39875

Release Notes:

- Fixed "open/copy permalink to line" paths not being URL-escaped

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Andrew Farkas
2025-10-09 18:33:05 +00:00
committed by GitHub
co-authored by Cole Miller
parent 2dfde55367
commit c24f365b69
12 changed files with 169 additions and 140 deletions
+15 -1
View File
@@ -5,9 +5,12 @@ use async_trait::async_trait;
use derive_more::{Deref, DerefMut};
use gpui::{App, Global, SharedString};
use http_client::HttpClient;
use itertools::Itertools;
use parking_lot::RwLock;
use url::Url;
use crate::repository::RepoPath;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct PullRequest {
pub number: u32,
@@ -55,10 +58,21 @@ pub struct BuildCommitPermalinkParams<'a> {
pub struct BuildPermalinkParams<'a> {
pub sha: &'a str,
pub path: &'a str,
/// URL-escaped path using unescaped `/` as the directory separator.
pub path: String,
pub selection: Option<Range<u32>>,
}
impl<'a> BuildPermalinkParams<'a> {
pub fn new(sha: &'a str, path: &RepoPath, selection: Option<Range<u32>>) -> Self {
Self {
sha,
path: path.components().map(urlencoding::encode).join("/"),
selection,
}
}
}
/// A Git hosting provider.
#[async_trait]
pub trait GitHostingProvider {