Skip to content

Commit 4673cd4

Browse files
committed
refactor: use URL object for more robust GitHub URL parsing
1 parent bf2b3ba commit 4673cd4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ui/modules/urlExport.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,14 @@ const urlExport = (parent, exportSettings: urlExportSettings, requestBody: urlEx
126126
}
127127

128128
if (exportSettings.authType === config.key.authType.githubCommit) {
129+
const url = new URL(exportSettings.url)
130+
const pathParts = url.pathname.split('/').filter(part => part.length > 0)
131+
const owner = pathParts[1] // /repos/owner/repo -> owner
132+
const repo = pathParts[2] // /repos/owner/repo -> repo
133+
129134
const githubRepo = new GithubRepository({
130-
owner: exportSettings.url.split('/')[3],
131-
repo: exportSettings.url.split('/')[4],
135+
owner,
136+
repo,
132137
token: exportSettings.accessToken
133138
})
134139
githubRepo.upload(requestBody, exportSettings, {

0 commit comments

Comments
 (0)