Skip to content

defineGitSource #3818

Description

@swisschard

Environment

Operating system Windows 10.0.26200
CPU 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 cores)
Node.js version v24.15.0
nuxt/cli version 3.36.1
Package manager npm@11.12.1
Nuxt version 4.4.8
Nitro version 2.13.4
Builder vite@7.3.6
Config compatibilityDate, content, devtools, modules
Modules @nuxt/content@3.15.0

Version

3.15.0

Reproduction

I think the issue is obvious and the below description is enough to understand the problem and solution.

Description

Hello,

When I define a collection source where the repository property is a url string that ends in .git like so:

source: {
    repository: 'https://git.domain.tld/repo.git',
    include: '**/*.json',
},

npm run dev throws a ERROR HTTP Error: 404 Not Found. I think it is because you don't add back the .git suffix when transforming the repository property from a string into an object (line 65-68 below):

export function defineGitSource(source: CollectionSource): ResolvedCollectionSource {
const resolvedSource = defineLocalSource(source)
resolvedSource.prepare = async ({ rootDir }) => {
if (typeof (source.repository) === 'string') {
const repository = source?.repository && gitUrlParse(source.repository)
if (repository) {
const { protocol, host, full_name, ref } = repository
source = {
...source,
repository: {
url: `${protocol}://${host}/${full_name}`,
branch: ref || 'main',
},
}
}
}

As a workaround, I can define my collection source repository as an object instead of a string like so:

source: {
    repository: {
        url: 'https://git.domain.tld/repo.git',
        branch: 'main',
    },
},

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions