chore: format (includes other middleware)

pull/552/head
Ame_x 2024-05-29 03:40:21 +00:00
parent ef318bef47
commit 16b4462014
5 changed files with 20 additions and 12 deletions

View File

@ -66,7 +66,6 @@ export interface SignOutParams<R extends boolean = true> {
redirect?: R
}
export interface SessionProviderProps {
children: React.ReactNode
session?: Session | null
@ -136,11 +135,11 @@ export function now() {
}
export function parseUrl(url?: string) {
const defaultUrl = 'http://localhost:3000/api/auth';
const parsedUrl = new URL(url?.startsWith('http') ? url : `https://${url}` || defaultUrl);
const defaultUrl = 'http://localhost:3000/api/auth'
const parsedUrl = new URL(url?.startsWith('http') ? url : `https://${url}` || defaultUrl)
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '');
const base = `${parsedUrl.origin}${path}`;
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '')
const base = `${parsedUrl.origin}${path}`
return {
origin: parsedUrl.origin,
@ -148,5 +147,5 @@ export function parseUrl(url?: string) {
path,
base,
toString: () => base,
};
}
}

View File

@ -192,8 +192,8 @@ describe('Credentials Provider', () => {
it('Should respect x-forwarded-proto and x-forwarded-host', async () => {
const headers = new Headers()
headers.append('x-forwarded-proto', "https")
headers.append('x-forwarded-host', "example.com")
headers.append('x-forwarded-proto', 'https')
headers.append('x-forwarded-host', 'example.com')
const res = await app.request('http://localhost/api/auth/signin', {
headers,
})

View File

@ -1,6 +1,15 @@
import { Hono } from 'hono'
import type { Equal, Expect } from 'hono/utils/types'
import { number, object, string, optional, numberAsync, objectAsync, stringAsync, optionalAsync } from 'valibot'
import {
number,
object,
string,
optional,
numberAsync,
objectAsync,
stringAsync,
optionalAsync,
} from 'valibot'
import { vValidator } from '../src'
// eslint-disable-next-line @typescript-eslint/no-unused-vars