From f85cb1fab63dfaf926ff4aa1b301810e9250547e Mon Sep 17 00:00:00 2001 From: Mads Erik Forberg Date: Wed, 3 Jan 2024 13:21:03 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/@types/astro.ts | 8 ++++++-- packages/astro/src/core/cookies/cookies.ts | 7 +++++-- packages/astro/src/core/cookies/index.ts | 2 +- packages/astro/test/units/cookies/get.test.js | 12 ++++++------ packages/astro/test/units/cookies/set.test.js | 12 ++++++------ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index ed6015757cc9..74cbb4694d9d 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -64,13 +64,17 @@ export type { } from '../assets/types.js'; export type { RemotePattern } from '../assets/utils/remotePattern.js'; export type { SSRManifest } from '../core/app/types.js'; -export type { AstroCookies, AstroCookieSetOptions, AstroCookieGetOptions } from '../core/cookies/index.js'; +export type { + AstroCookies, + AstroCookieSetOptions, + AstroCookieGetOptions, +} from '../core/cookies/index.js'; export interface AstroBuiltinProps { 'client:load'?: boolean; 'client:idle'?: boolean; 'client:media'?: string; - 'client:visible'?: string|boolean; + 'client:visible'?: string | boolean; 'client:only'?: boolean | string; } diff --git a/packages/astro/src/core/cookies/cookies.ts b/packages/astro/src/core/cookies/cookies.ts index 7ed87b3ca91e..f9214c48345f 100644 --- a/packages/astro/src/core/cookies/cookies.ts +++ b/packages/astro/src/core/cookies/cookies.ts @@ -15,7 +15,7 @@ export interface AstroCookieSetOptions { export interface AstroCookieGetOptions { decode?: (value: string) => string; -}; +} type AstroCookieDeleteOptions = Pick; @@ -102,7 +102,10 @@ class AstroCookies implements AstroCookiesInterface { * @param key The cookie to get. * @returns An object containing the cookie value as well as convenience methods for converting its value. */ - get(key: string, options: AstroCookieGetOptions | undefined = undefined): AstroCookie | undefined { + get( + key: string, + options: AstroCookieGetOptions | undefined = undefined + ): AstroCookie | undefined { // Check for outgoing Set-Cookie values first if (this.#outgoing?.has(key)) { let [serializedValue, , isSetValue] = this.#outgoing.get(key)!; diff --git a/packages/astro/src/core/cookies/index.ts b/packages/astro/src/core/cookies/index.ts index 912fd2721e19..1ac732f1b1fb 100644 --- a/packages/astro/src/core/cookies/index.ts +++ b/packages/astro/src/core/cookies/index.ts @@ -4,4 +4,4 @@ export { getSetCookiesFromResponse, responseHasCookies, } from './response.js'; -export type { AstroCookieSetOptions, AstroCookieGetOptions } from "./cookies.js"; \ No newline at end of file +export type { AstroCookieSetOptions, AstroCookieGetOptions } from './cookies.js'; diff --git a/packages/astro/test/units/cookies/get.test.js b/packages/astro/test/units/cookies/get.test.js index 104ff1f759bb..a8bc0d4b5217 100644 --- a/packages/astro/test/units/cookies/get.test.js +++ b/packages/astro/test/units/cookies/get.test.js @@ -17,27 +17,27 @@ describe('astro/src/core/cookies', () => { }); it('gets the cookie value with default decode', () => { - const url = 'http://localhost'; + const url = 'http://localhost'; const req = new Request('http://example.com/', { headers: { cookie: `url=${encodeURIComponent(url)}`, }, }); const cookies = new AstroCookies(req); - // by default decodeURIComponent is used on the value + // by default decodeURIComponent is used on the value expect(cookies.get('url').value).to.equal(url); }); - + it('gets the cookie value with custom decode', () => { - const url = 'http://localhost'; + const url = 'http://localhost'; const req = new Request('http://example.com/', { headers: { cookie: `url=${encodeURIComponent(url)}`, }, }); const cookies = new AstroCookies(req); - // set decode to the identity function to prevent decodeURIComponent on the value - expect(cookies.get('url', { decode: o => o }).value).to.equal(encodeURIComponent(url)); + // set decode to the identity function to prevent decodeURIComponent on the value + expect(cookies.get('url', { decode: (o) => o }).value).to.equal(encodeURIComponent(url)); }); it("Returns undefined is the value doesn't exist", () => { diff --git a/packages/astro/test/units/cookies/set.test.js b/packages/astro/test/units/cookies/set.test.js index 16c0d2e874ac..a583aa1ca34d 100644 --- a/packages/astro/test/units/cookies/set.test.js +++ b/packages/astro/test/units/cookies/set.test.js @@ -18,23 +18,23 @@ describe('astro/src/core/cookies', () => { it('Sets a cookie value that can be serialized w/ defaultencodeURIComponent behavior', () => { let req = new Request('http://example.com/'); let cookies = new AstroCookies(req); - const url = 'http://localhost/path'; + const url = 'http://localhost/path'; cookies.set('url', url); let headers = Array.from(cookies.headers()); expect(headers).to.have.a.lengthOf(1); - // by default cookie value is URI encoded + // by default cookie value is URI encoded expect(headers[0]).to.equal(`url=${encodeURIComponent(url)}`); }); it('Sets a cookie value that can be serialized w/ custom encode behavior', () => { let req = new Request('http://example.com/'); let cookies = new AstroCookies(req); - const url = 'http://localhost/path'; - // set encode option to the identity function - cookies.set('url', url, { encode: o => o }); + const url = 'http://localhost/path'; + // set encode option to the identity function + cookies.set('url', url, { encode: (o) => o }); let headers = Array.from(cookies.headers()); expect(headers).to.have.a.lengthOf(1); - // no longer URI encoded + // no longer URI encoded expect(headers[0]).to.equal(`url=${url}`); });