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:
co-authored by
Cole Miller
parent
2dfde55367
commit
c24f365b69
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user