Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/composables/useRepositoryUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function useRepositoryUrl(
let url = normalizeGitUrl(repo.url)

// append `repository.directory` for monorepo packages
if (repo.directory) {
url = joinURL(`${url}/tree/HEAD`, repo.directory)
if (repo.directory && url) {
url = joinURL(url.replace(/\.git$/, ''), `/tree/HEAD`, repo.directory)
Comment on lines +22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this directly into the normalizeGitUrl function in git-providers.ts, so it doesn't need to be repeated elsewhere.

}

return url
Expand Down
36 changes: 36 additions & 0 deletions test/nuxt/composables/use-repository-url.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { describe, expect, it } from 'vitest'

const fakeRequestedVersion = (
data: Partial<SlimPackument['requestedVersion']>,
): SlimPackument['requestedVersion'] => {
return {
_id: 'any',
_npmVersion: 'idk',
dist: {
shasum: '',
signatures: [],
tarball: '',
},
name: 'any',
version: '0.0.1',
...data,
}
}

describe('useRepositoryUrl', () => {
it('should have valid github repository url', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add the test to the git-providers.spec.ts file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i continue the pr or should i let bluwy handle it?

const test = fakeRequestedVersion({
repository: {
type: 'git',
url: 'git+https://github.com/nuxt/nuxt.git',
directory: 'packages/nuxt',
},
})

const result = useRepositoryUrl(test)

expect(result.repositoryUrl.value).toEqual(
'https://github.com/nuxt/nuxt/tree/HEAD/packages/nuxt',
)
})
})
Loading