Skip to content

Commit e57f284

Browse files
icecrasher321claude
andcommitted
chore(urls): stop claiming path-prefixed base URLs are supported
The previous commit's doc and test said a path-prefixed base keeps its path. That reads as support for a deployment shape the app does not have: there is no Next `basePath`, so routes are served at the origin root and such a value could not address them however the base were normalized. Every documented example is origin-only. Says only what is true — trailing slashes are the one spelling absorbed — and reframes the test as pinning the trim's shape rather than asserting a path-prefixed deployment works. No behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 5e8e10b commit e57f284

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

apps/sim/lib/core/utils/urls.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ describe('getBaseUrl', () => {
7474
}
7575
})
7676

77-
it('keeps the path of a path-prefixed base URL', () => {
77+
/**
78+
* Pins the trim's shape — it must not eat more than the trailing slashes.
79+
* Not a claim that a path-prefixed deployment works: the app declares no Next
80+
* `basePath`, so such a value could not address its routes either way.
81+
*/
82+
it('trims only trailing slashes, never interior ones', () => {
7883
mockGetEnv.mockImplementation((key) =>
79-
key === 'NEXT_PUBLIC_APP_URL' ? 'https://example.com/sim/' : undefined
84+
key === 'NEXT_PUBLIC_APP_URL' ? 'https://example.com/a/b/' : undefined
8085
)
81-
expect(getBaseUrl()).toBe('https://example.com/sim')
86+
expect(getBaseUrl()).toBe('https://example.com/a/b')
8287
})
8388

8489
it('adds the protocol and strips the trailing slash together', () => {

apps/sim/lib/core/utils/urls.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ function hasHttpProtocol(url: string): boolean {
2222
* route, and breaks the `startsWith(`${base}/`)` prefix checks that decide
2323
* whether a redirect target is our own. Normalizing once here is what lets
2424
* those call sites stay simple instead of each defending against the operator's
25-
* spelling. A path-prefixed base (`https://host/sim/`) keeps its path.
25+
* spelling.
26+
*
27+
* Trailing slashes are the only spelling this absorbs. The app declares no Next
28+
* `basePath`, so its routes are served at the origin root and a path-prefixed
29+
* value could not address them however this normalized it.
2630
*/
2731
function normalizeBaseUrl(url: string): string {
2832
const protocol = isProd ? 'https://' : 'http://'

0 commit comments

Comments
 (0)