Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop-app-r7-h2): normalize REST URL identity

Josuéddcf3532edae
diff --git a/desktop-app/src/__tests__/desktopEnvironmentUrl.test.ts b/desktop-app/src/__tests__/desktopEnvironmentUrl.test.ts
new file mode 100644
index 000000000..9bc9d82a2
--- /dev/null
+++ b/desktop-app/src/__tests__/desktopEnvironmentUrl.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from 'vitest'
+import { canonicalizeDesktopRestEndpoint, sameDesktopRestEndpoint } from '../desktopEnvironmentUrl'
+
+describe('Desktop REST endpoint identity', () => {
+ it('ignores trailing path slashes and URL fragments', () => {
+ expect(
+ canonicalizeDesktopRestEndpoint('https://api.example.test/external-rest-api/#tenant-section')
+ ).toBe('https://api.example.test/external-rest-api')
+ expect(
+ sameDesktopRestEndpoint(
+ 'https://api.example.test/external-rest-api/',
+ 'https://api.example.test/external-rest-api'
+ )
+ ).toBe(true)
+ })
+
+ it('keeps different paths on the same REST host distinct', () => {
+ expect(
+ sameDesktopRestEndpoint(
+ 'https://api.example.test/external-rest-api/a',
+ 'https://api.example.test/external-rest-api/b'
+ )
+ ).toBe(false)
+ })
+})
diff --git a/desktop-app/src/desktopEnvironmentUrl.ts b/desktop-app/src/desktopEnvironmentUrl.ts
index cce6ba086..4173f4482 100644
--- a/desktop-app/src/desktopEnvironmentUrl.ts
+++ b/desktop-app/src/desktopEnvironmentUrl.ts
@@ -13,8 +13,8 @@ export function canonicalizeDesktopRestEndpoint(rawValue: string): string {
url.hostname = hostnameWithoutRootDot
}
- const pathname = url.pathname === '/' ? '' : url.pathname
- return `${url.origin}${pathname}${url.search}${url.hash}`
+ const pathname = url.pathname.replace(/\/+$/, '')
+ return `${url.origin}${pathname}${url.search}`
}
export function desktopRestEndpointOrigin(rawValue: string): string {