Files
speckle-server/packages/frontend-2/lib/common/helpers/github.ts
T
Kristaps Fabians Geikins 1d2a594f0a chore: upgrade TS 5.2 -> 5.7.3 & ESLint to 9.20.1 (#4032)
* chore: upgrade TS 5.2 -> 5.7.3

* vite dts fix

* lint fix

* resolutions fix

* ui comp build fix

* precommit fix?

* latest eslint version

* autoloader fix

* undo unnecessary viewer change

* eslint fixes fe2 + trying disabled type linting

* lint fixes
2025-02-20 14:18:18 +02:00

36 lines
836 B
TypeScript

import type { MaybeNullOrUndefined, Nullable } from '@speckle/shared'
export const parseGithubRepoUrl = (
url: MaybeNullOrUndefined<string>
): Nullable<{ owner: string; name: string }> => {
if (!url?.length) return null
let repoUrl: URL
try {
repoUrl = new URL(url)
} catch {
return null
}
const pathParts = repoUrl.pathname.split('/').filter(Boolean)
if (pathParts.length < 2) {
return null
}
const [owner, name] = pathParts
return { owner, name }
}
export const buildGithubRepoSshUrl = (params: { owner: string; name: string }) => {
const { owner, name } = params
return `git@github.com:${owner}/${name}.git`
}
export const buildGithubRepoHttpCloneUrl = (params: {
owner: string
name: string
}) => {
const { owner, name } = params
return `https://github.com/${owner}/${name}.git`
}