Skip to content

Commit f2a3026

Browse files
auto: format code
1 parent 754d776 commit f2a3026

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

packages/openauth/src/issuer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ export function issuer<
715715
}
716716

717717
function issuer(ctx: Context) {
718-
return (new URL(getRelativeUrl(ctx, '/'))).origin
718+
return new URL(getRelativeUrl(ctx, "/")).origin
719719
}
720720

721721
const app = new Hono<{

packages/openauth/src/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Context } from "hono";
1+
import { Context } from "hono"
22

33
export type Prettify<T> = {
44
[K in keyof T]: T[K]
@@ -7,8 +7,8 @@ export type Prettify<T> = {
77
export function getRelativeUrl(ctx: Context, path: string) {
88
const result = new URL(path, ctx.req.url)
99
result.host = ctx.req.header("x-forwarded-host") || result.host
10-
result.protocol = ctx.req.header("x-forwarded-proto") || result.protocol;
11-
result.port = ctx.req.header("x-forwarded-port") || result.port;
10+
result.protocol = ctx.req.header("x-forwarded-proto") || result.protocol
11+
result.port = ctx.req.header("x-forwarded-port") || result.port
1212
return result.toString()
1313
}
1414

packages/openauth/test/util.test.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,33 @@ test("isDomainMatch", () => {
7171

7272
test("getRelativeUrl", () => {
7373
// Helper to create a mock Context
74-
const createMockContext = (url: string, headers: Record<string, string> = {}) => {
74+
const createMockContext = (
75+
url: string,
76+
headers: Record<string, string> = {},
77+
) => {
7578
return {
7679
req: {
7780
url,
78-
header: (name: string) => headers[name.toLowerCase()] || '',
81+
header: (name: string) => headers[name.toLowerCase()] || "",
7982
},
80-
} as Context;
81-
};
83+
} as Context
84+
}
8285

8386
// Test basic URL construction
84-
const ctx1 = createMockContext('http://example.com');
85-
expect(getRelativeUrl(ctx1, '/path')).toBe('http://example.com/path');
86-
87+
const ctx1 = createMockContext("http://example.com")
88+
expect(getRelativeUrl(ctx1, "/path")).toBe("http://example.com/path")
89+
8790
// Test with x-forwarded headers
88-
const ctx2 = createMockContext('http://original.com', {
89-
'x-forwarded-host': 'forwarded.com',
90-
'x-forwarded-proto': 'https',
91-
'x-forwarded-port': '443'
92-
});
93-
expect(getRelativeUrl(ctx2, '/path')).toBe('https://forwarded.com/path');
91+
const ctx2 = createMockContext("http://original.com", {
92+
"x-forwarded-host": "forwarded.com",
93+
"x-forwarded-proto": "https",
94+
"x-forwarded-port": "443",
95+
})
96+
expect(getRelativeUrl(ctx2, "/path")).toBe("https://forwarded.com/path")
9497

9598
// Test with absolute URLs
96-
const ctx4 = createMockContext('http://example.com');
97-
expect(getRelativeUrl(ctx4, 'http://other.com/path')).toBe('http://other.com/path');
98-
});
99+
const ctx4 = createMockContext("http://example.com")
100+
expect(getRelativeUrl(ctx4, "http://other.com/path")).toBe(
101+
"http://other.com/path",
102+
)
103+
})

0 commit comments

Comments
 (0)