Skip to content

[BUG]: Undefined slash-parameters likely expanded incorrectly #395

@amezin

Description

@amezin

What happened?

> const { endpoint } = require("@octokit/endpoint");
> endpoint("http://api.github.com/repos/octocat/Hello-World/branches{/branch}", {})
{
  method: 'GET',
  url: 'http://api.github.com/repos/octocat/Hello-World/branches/',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'octokit-endpoint.js/7.0.4 Node.js/19.4.0 (linux; x64)'
  }
}

Note the slash at the end of url. GitHub returns 404 for .../branches/, but lists branches for .../branches.

Expanding the same URL with url-template and empty context returns .../branches. This makes me belive that endpoint.js performs template expansion incorrectly.

Versions

Octokit.js v7.0.4, Node v19.4.0

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedhacktoberfestIssues for participation in Hacktoberfestreleased

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions