cli icon indicating copy to clipboard operation
cli copied to clipboard

logs --url rejects branch deploy URLs when the branch contains double hyphens

Open r4venrudy opened this issue 1 month ago • 0 comments

Describe the bug

resolveDeployIdFromUrl splits the first hostname label at the first --. A branch named feature--logs therefore makes https://feature--logs--my-site.netlify.app fail the linked-project check for my-site, before any deploy lookup occurs. Site names containing -- also need to remain supported when fixing the split.

The same parsing accepts a first label such as staging--my-site even when an extra label follows it (staging--my-site.extra.netlify.app), and accepts an empty branch prefix.

Steps to reproduce

Offline unit reproduction at main commit 31ed36f00f9fbf0207fd7c0a47f4b767c468b8b9:

const client = {
  listSiteDeploys: async () => [{ id: "branch-deploy", state: "ready" }],
}
await resolveDeployIdFromUrl(
  "https://feature--logs--my-site.netlify.app",
  client as never,
  "site-id",
  { name: "my-site" },
)

Expected: resolve branch-deploy by querying branch feature--logs. Actual: The URL ... doesn't seem to match the linked project (my-site).

The corresponding command is netlify logs --url https://feature--logs--my-site.netlify.app for a linked site with that branch deploy. The reproduction above isolates the parser without a live site or API credentials.

Configuration

No special configuration; the relevant site metadata is { name: "my-site" }.

Environment

Netlify CLI 27.12.0 source at the commit above; Windows x64; Node v24.14.1. Ten local resolver cases reproduce four failures: two branch-name cases and two invalid-host/prefix cases.

r4venrudy avatar Oct 11 '26 15:10 r4venrudy