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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test-rust:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/sync-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ on:
schedule:
- cron: "0 6 * * *"

permissions:
contents: read

jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4

Expand Down
10 changes: 9 additions & 1 deletion typescript/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Everruns {
// Example: "http://host/api/" + "/v1/agents" = "http://host/api//v1/agents" (wrong)
// "http://host/api" + "/v1/agents" = "http://host/api/v1/agents" (correct)
const rawBaseUrl = options.baseUrl ?? "https://custom.example.com/api";
this.baseUrl = rawBaseUrl.replace(/\/+$/, "");
this.baseUrl = trimTrailingSlashes(rawBaseUrl);
const orgId =
options.orgId !== undefined
? options.orgId
Expand Down Expand Up @@ -231,6 +231,14 @@ function validateOrgId(orgId: string | undefined): string | undefined {
return orgId;
}

function trimTrailingSlashes(value: string): string {
let end = value.length;
while (end > 0 && value.charCodeAt(end - 1) === 47) {
end -= 1;
}
return value.slice(0, end);
}

class AgentsClient {
constructor(private readonly client: Everruns) {}

Expand Down
10 changes: 10 additions & 0 deletions typescript/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ describe("Everruns", () => {
);
});

it("should normalize base URL with multiple trailing slashes", () => {
const client = new Everruns({
apiKey: "evr_test_key",
baseUrl: "https://custom.api.com/api///",
});
expect(client.getStreamUrl("/agents")).toBe(
"https://custom.api.com/api/v1/agents",
);
});

it("should create session with initial files", async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
Expand Down
Loading