Skip to content

Commit

Permalink
Release v3.1.1 (#246)
Browse files Browse the repository at this point in the history
Co-authored-by: Hurby <69755274+hurby24@users.noreply.github.com>
  • Loading branch information
pilcrowonpaper and hurby24 authored Jan 9, 2025
1 parent bb87ae9 commit 79a6c58
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions .RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix Authentik endpoints ([#244](https://github.com/pilcrowonpaper/arctic/issues/244)).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arctic",
"type": "module",
"version": "3.1.0",
"version": "3.1.1",
"description": "OAuth 2.0 clients for popular providers",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/providers/authentik.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class Authentik {
private client: OAuth2Client;

constructor(baseURL: string, clientId: string, clientSecret: string | null, redirectURI: string) {
this.authorizationEndpoint = joinURIAndPath(baseURL, "/application/o/authorize");
this.tokenEndpoint = joinURIAndPath(baseURL, "/application/o/token");
this.tokenRevocationEndpoint = joinURIAndPath(baseURL, "/application/o/revoke");
this.authorizationEndpoint = joinURIAndPath(baseURL, "/application/o/authorize/");
this.tokenEndpoint = joinURIAndPath(baseURL, "/application/o/token/");
this.tokenRevocationEndpoint = joinURIAndPath(baseURL, "/application/o/revoke/");
this.client = new OAuth2Client(clientId, clientSecret, redirectURI);
}

Expand Down
21 changes: 21 additions & 0 deletions src/request.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as vitest from "vitest";

import { joinURIAndPath } from "./request.js";

vitest.test("joinBaseURIAndPath()", () => {
vitest.expect(joinURIAndPath("https://example.com", "/hi")).toBe("https://example.com/hi");
vitest.expect(joinURIAndPath("https://example.com/", "/hi")).toBe("https://example.com/hi");
vitest.expect(joinURIAndPath("https://example.com/", "hi")).toBe("https://example.com/hi");
vitest.expect(joinURIAndPath("https://example.com", "hi")).toBe("https://example.com/hi");
vitest.expect(joinURIAndPath("https://example.com", "/hi/")).toBe("https://example.com/hi/");

vitest
.expect(joinURIAndPath("https://example.com", "/hi", "/bye"))
.toBe("https://example.com/hi/bye");
vitest
.expect(joinURIAndPath("https://example.com", "hi", "bye"))
.toBe("https://example.com/hi/bye");
vitest
.expect(joinURIAndPath("https://example.com", "/hi/", "/bye/"))
.toBe("https://example.com/hi/bye/");
});
3 changes: 1 addition & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { trimLeft, trimRight } from "./utils.js";
export function joinURIAndPath(base: string, ...path: string[]): string {
let joined = trimRight(base, "/");
for (const part of path) {
joined += "/";
joined += trimRight(trimLeft(part, "/"), "/");
joined = trimRight(joined, "/") + "/" + trimLeft(part, "/");
}
return joined;
}
Expand Down

0 comments on commit 79a6c58

Please sign in to comment.