GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(usage): a CLIProxy hub saved as its management.html panel URL sho… · pingdotgg/t3code@24fbb5d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/usage
    • cliproxyApi.test.ts
    • cliproxyApi.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/usage/cliproxyApi.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/usage/cliproxyApi.test.ts
+26-2Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,42 @@ describe("CLIProxyAPI built-in management API", () => {
264264
}),
265265
);
266266

267-
it.effect("keeps the path of a hub served under a prefix", () =>
267+
it.effect.each([
268+
"https://tools.test/cliproxy",
269+
"https://tools.test/cliproxy/",
270+
"https://tools.test/cliproxy/management.html",
271+
"https://tools.test/cliproxy/management.html/",
272+
"https://tools.test/cliproxy/MANAGEMENT.HTML",
273+
"https://tools.test/cliproxy/management.html?tab=accounts",
274+
"https://tools.test/cliproxy/management.html#accounts",
275+
"https://tools.test/cliproxy/management.html/?tab=accounts",
276+
"https://tools.test/cliproxy/management.html/#accounts",
277+
])("keeps the path of a hub served under a prefix: %s", (url) =>
268278
Effect.gen(function* () {
269279
const test = fixture();
270280
const api = yield* test.api;
271-
yield* api.readAccounts({ ...config, url: "https://tools.test/cliproxy" });
281+
yield* api.readAccounts({ ...config, url });
272282
expect(test.requests.length).toBeGreaterThan(0);
273283
expect(
274284
test.requests.every((request) => request.path.startsWith("/cliproxy/v0/management/")),
275285
).toBe(true);
276286
}),
277287
);
278288

289+
it.effect("preserves a hub path that only ends with the panel filename", () =>
290+
Effect.gen(function* () {
291+
const test = fixture();
292+
const api = yield* test.api;
293+
yield* api.readAccounts({ ...config, url: "https://tools.test/team-management.html" });
294+
expect(test.requests.length).toBeGreaterThan(0);
295+
expect(
296+
test.requests.every((request) =>
297+
request.path.startsWith("/team-management.html/v0/management/"),
298+
),
299+
).toBe(true);
300+
}),
301+
);
302+
279303
it.effect("keeps usage when the credits endpoint fails", () =>
280304
Effect.gen(function* () {
281305
const test = fixture({
Collapse file

‎apps/server/src/usage/cliproxyApi.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/usage/cliproxyApi.ts
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ export const makeCliproxyApi = Effect.gen(function* () {
184184
body?: unknown,
185185
) {
186186
const url = yield* Effect.try({
187-
try: () =>
188-
new URL(
189-
`v0/management/${path}`,
190-
hub.url.endsWith("/") ? hub.url : `${hub.url}/`,
191-
).toString(),
187+
try: () => {
188+
const base = new URL(hub.url);
189+
// Users often paste the hub's web panel URL, which ends in management.html.
190+
base.pathname = base.pathname.replace(/(\/management\.html)?\/?$/i, "/");
191+
return new URL(`v0/management/${path}`, base).toString();
192+
},
192193
catch: () => new UsageLimitSourceError({ detail: "The hub URL is not valid." }),
193194
});
194195
const request = (

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.