Skip to content

/repos/{owner}/{name}/files/{branch} doesn't work #124

@ota-meshi

Description

@ota-meshi

Environment

Chrome 136.0.7103.114

Reproduction

Go to https://ungh.cc/repos/unjs/h3/files/main.
It will redirect to https://raw.githubusercontent.com/unjs/h3/main and give you a 400 error.

Describe the bug

This issue was derived from #123 (comment).

The /repos/{owner}/{name}/files/{branch}/{...path} endpoint was intentionally changed to redirect in the commit 91ad7e2.
However, the current situation is that the /repos/{owner}/{name}/files/{branch} endpoint also redirects.
I believe that was not intended.

This endpoint is still listed in the documentation.

https://github.com/unjs/ungh/blob/main/README.md#reposownernamefilesbranch

Additional context

Since you said "PR welcome", I tried to find the cause of this problem by forking and debugging.

However, when I run npm run dev locally to start the server and access http://localhost:3000/repos/unjs/h3/files/main, it doesn't get redirected.
Do you know what's going on?

Logs

Request URL https://ungh.cc/repos/unjs/h3/files/main
Request Method GET
Status Code 302 Found
location https://raw.githubusercontent.com/unjs/h3/main

---

Request URL https://raw.githubusercontent.com/unjs/h3/main
Request Method GET
Status Code 400 Bad Request

---

400: Invalid request

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions