Skip to content

Fix trailing slash dropped when joining route segments#10071

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-regression-http-1-10-1
Draft

Fix trailing slash dropped when joining route segments#10071
Copilot wants to merge 3 commits intomainfrom
copilot/fix-regression-http-1-10-1

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

Explicit trailing / on interface routes was being dropped when joined with child route segments starting with ? or :.

@route("{blobName}/")
interface Blobs {
  @put @route("?some-query=true")
  putBlob(blobName: string, @body content: bytes): void;
  // Expected:  /{blobName}/?some-query=true
  // Actual:    /{blobName}?some-query=true
}

Root cause: normalizeFragment unconditionally trimmed trailing / from all non-last segments, even when the next segment doesn't start with /.

Fix: Replace the blanket trimLast behavior with // deduplication at the join point — only strip a / when concatenation would produce a double slash.

Original prompt

This section details on the original issue you should resolve

<issue_title>Regression from http 1.10.1</issue_title>
<issue_description>Explicit / is now dropped when defined on interface.
When joining with parent routes we seem to drop an explicit trailing /. this feels quite like an edge case but this isn't expected

playground

@route("{blobName}/")
interface Blobs {
  // expected:  /{blobName}/?some-query=true
  // actual:  /{blobName}?some-query=true
  @put
  @route("?some-query=true")
  putBlob(blobName: string, @body content: bytes): void; 
}
```</issue_description>

<agent_instructions>The route joining algorithm should be smarter and not trim `/` if it is relevent. Only trim it if it would result in a `//` </agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 18, 2026 18:33
…t in double slash

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix regression from http 1.10.1 Fix trailing slash dropped when joining route segments Mar 18, 2026
Copilot AI requested a review from timotheeguerin March 18, 2026 18:37
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http@10071

commit: 96d0848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression from http 1.10.1

2 participants