Skip to content

Fix trailing slash dropped when joining route segments - #10071

Open
Timothee Guerin (timotheeguerin) with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-regression-http-1-10-1
Open

Timothee Guerin (timotheeguerin) with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-regression-http-1-10-1

Conversation

Copilot AI commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

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
@pkg-pr-new

pkg-pr-new Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 56bc4ef

@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Apr 18, 2026
@timotheeguerin Timothee Guerin (timotheeguerin) removed the stale Mark a PR that hasn't been recently updated and will be closed. label Apr 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http
Show changes

@typespec/http - fix ✏️

Fix route joining to preserve trailing / when it would not result in //

@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label May 29, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Hi @Copilot. Your PR has had no update for 30 days and it is marked as a stale PR. If it is not updated within 30 days, the PR will automatically be closed. If you want to refresh the PR, please remove the stale label.

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Hi @Copilot. The PR will be closed since the PR has no update for 28 days. If this is still relevant please reopen.

@timotheeguerin Timothee Guerin (timotheeguerin) added the int:azure-specs Run integration tests against azure-rest-api-specs label Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Path-style expansions retain the parent route’s trailing slash, generating URLs such as /foo//42 and triggering double-slash warnings.

1 open issue
What changed in this PR

This PR fixes HTTP route joining so explicit trailing slashes are preserved before child routes beginning with ? or :.

Changes:

  • Replaces unconditional trailing-slash trimming with slash deduplication at route boundaries.
  • Adds regression tests for preserving parent-route trailing slashes.
  • Adds a changelog entry for @typespec/http.
File Description
packages/​http/​test/​routes.test.ts Tests trailing-slash preservation before ? and : child routes.
packages/​http/​src/​route.ts Changes route joining to deduplicate boundary slashes.
.chronus/​changes/​copilot-fix-regression-http-1-10-1-2026-2-18-18-33-49.md Documents the HTTP route-joining fix.

Review effort: Balanced

Comment thread packages/http/src/route.ts Resolved
@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copilot AI balanced review requested due to automatic review settings November 2, 2026 19:02
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the stale Mark a PR that hasn't been recently updated and will be closed. label Nov 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The route join logic fails to trim a preceding slash before {/ path-expansion fragments, producing double-slash URLs and diagnostics; this case needs a fix and regression test.

1 open issue

Review effort: Balanced

@markcowl Mark Cowlishaw (markcowl) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the copilot review is fairly accurate - should also have a test validating the additional scenario

Comment thread packages/http/src/route.ts Resolved
Copilot AI balanced review requested due to automatic review settings November 6, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the HTTP route-joining fix.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 19, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the route-joining fix.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

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

Labels

int:azure-specs Run integration tests against azure-rest-api-specs lib:http

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression from http 1.10.1

4 participants