Skip to content

Commit d4bbb46

Browse files
committed
explicitly filter out branch names with slash
1 parent d1fce01 commit d4bbb46

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/lib/sources/gitHubSource.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { DirSource, FileMetadata, FileSource, SourcePart } from './types.js'
22
import { getFileName } from './utils.js'
33

4-
// TODO(SL): support branches with slashes in their names (feature/foo)
5-
64
interface BaseUrl {
75
source: string
86
origin: string
@@ -106,7 +104,10 @@ export function getGitHubSource(sourceId: string, options?: {requestInit?: Reque
106104
const branches = await fetchBranchesList(url, options)
107105
return {
108106
label: 'Branches',
109-
versions: branches.map((branch) => {
107+
versions: branches.filter(
108+
// TODO(SL): support branches with slashes in their names (feature/foo/bar)
109+
branch => !branch.includes('/')
110+
).map((branch) => {
110111
const branchSourceId = `${baseUrl}/${url.repo}/${url.kind === 'file' ? 'blob' : 'tree'}/${branch}${path}`
111112
return {
112113
label: branch,
@@ -139,6 +140,7 @@ export function getGitHubSource(sourceId: string, options?: {requestInit?: Reque
139140
}
140141
}
141142

143+
// TODO(SL): support branches with slashes in their names (feature/foo)
142144
export function parseGitHubUrl(url: string): GHUrl {
143145
const urlObject = new URL(url)
144146
// ^ throws 'TypeError: URL constructor: {url} is not a valid URL.' if url is not a valid URL

0 commit comments

Comments
 (0)