Skip to content

Commit 7895eb3

Browse files
committed
support /raw/
1 parent c26014c commit 7895eb3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/lib/sources/gitHubSource.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface DirectoryUrl extends BaseUrl {
1616

1717
interface FileUrl extends BaseUrl {
1818
kind: 'file'
19-
action?: 'blob' | 'raw/refs/heads'
19+
action?: 'blob' | 'raw' | 'raw/refs/heads'
2020
resolveUrl: string
2121
}
2222

@@ -226,7 +226,7 @@ export function parseGitHubUrl(url: string): GHUrl {
226226
// https://github.com/apache/parquet-testing/blob/master/variant/README.md
227227
// https://github.com/apache/parquet-testing/raw/refs/heads/master/variant/README.md
228228
const fileGroups =
229-
/^\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?<action>blob|refs\/heads|raw\/refs\/heads)\/(?<branch>[^/]+)(?<path>(\/[^/]+)+)$/.exec(
229+
/^\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?<action>blob|raw|raw\/refs\/heads)\/(?<branch>[^/]+)(?<path>(\/[^/]+)+)$/.exec(
230230
pathname
231231
)?.groups
232232
if (
@@ -243,10 +243,10 @@ export function parseGitHubUrl(url: string): GHUrl {
243243
source,
244244
origin: urlObject.origin,
245245
repo: fileGroups.owner + '/' + fileGroups.repo,
246-
action: fileGroups.action === 'blob' ? 'blob' : 'raw/refs/heads',
246+
action: fileGroups.action === 'blob' ? 'blob' : fileGroups.action === 'raw' ? 'raw' : 'raw/refs/heads',
247247
branch,
248248
path: fileGroups.path,
249-
resolveUrl: `${baseRawUrl}/${fileGroups.owner}/${fileGroups.repo}/refs/heads/${branch}${fileGroups.path}`,
249+
resolveUrl: `${baseRawUrl}/${fileGroups.owner}/${fileGroups.repo}/${branch}${fileGroups.path}`,
250250
}
251251
}
252252

0 commit comments

Comments
 (0)