Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/runtime-oauth-polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function escape(value: string): string {
function namedFunction(runtime: string, label: string): FunctionExpression {
const name = symbol(runtime, label);
const match = unique(
[...runtime.matchAll(new RegExp(`(?:async )?function ${name}\\(`, "gu"))],
[...runtime.matchAll(new RegExp(`(?:async )?function ${escape(name)}\\(`, "gu"))],
`${label} function`
);
const fn = parseExpressionAt(runtime, match.index!, { ecmaVersion: "latest" });
Expand Down
20 changes: 20 additions & 0 deletions test/runtime/oauth-polling.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect, test } from "bun:test";
import { hasRuntimeNativePollingOAuth } from "../../scripts/runtime-oauth-polling.ts";

test("native OAuth polling recognizes dollar signs in minified function names", () => {
const runtime = `
r(login$,"loginZCodeCli");
r(bigmodel$,"loginBigmodelCodingPlan");
r(poll$,"pollUntilReady");
async function login$(e={}) {
const credentialKeys={}, oauth={};
poll$({authSource:"oauth"});
return {authSource:"oauth",[credentialKeys.zcodeJwtToken]:oauth.token,[credentialKeys.bigmodelAccessToken]:oauth.accessToken,};
}
async function bigmodel$(e={}) {
return login$({...e,providerId:"bigmodel"});
}
`;

expect(hasRuntimeNativePollingOAuth(runtime)).toBe(true);
});
Loading