Skip to content
Myr

chore(april-fool): change `hono is cool` to `hono is hot` (#4035)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* april-fool: change `hono is cool` to `hono is hot` * chore: format * fix: test * chore * Update accept.test.ts * chore * chore * chore * chore * chore * chore * chore * all changed * chore: format

authored by EdamAmex · committed by GitHub · parent 2c3e1ae · Browse files · 20 files+50 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

20 files+50 added−57 removed

  • tests:+42 added−48 removed
  • other:+8 added−9 removed

20 files+50 added−57 removed

modified:docs/CONTRIBUTING.md+1 added-1 removed
modified:runtime-tests/deno/middleware.test.tsx+2 added-2 removed
11 unmodified lines
12Deno.test('Basic Auth Middleware', async () => {13 const app = new Hono()1415 const username = 'hono'16 const password = 'acoolproject'16 const password = 'ahotproject'1718 app.use(19 '/auth/*',20 basicAuth({
7 unmodified lines
28 const res = await app.request('http://localhost/auth/a')29 assertEquals(res.status, 401)30 assertEquals(await res.text(), 'Unauthorized')3132 const credential = 'aG9ubzphY29vbHByb2plY3Q='32 const credential = 'aG9ubzphaG90cHJvamVjdA=='3334 const req = new Request('http://localhost/auth/a')35 req.headers.set('Authorization', `Basic ${credential}`)36 const resOK = await app.request(req)
150 unmodified lines
modified:runtime-tests/lambda-edge/index.test.ts-1 removed
1/* eslint-disable quotes */1import type {2 Callback,3 CloudFrontConfig,4 CloudFrontRequest,
1130 unmodified lines
modified:src/adapter/cloudflare-pages/handler.test.ts+5 added-5 removed
16 unmodified lines
17 data: {},18 env: {19 ...context.env,20 ASSETS: { fetch: vi.fn(), ...context.env?.ASSETS },21 TOKEN: context.env?.TOKEN ?? 'HONOISCOOL',21 TOKEN: context.env?.TOKEN ?? 'HONOISHOT',22 },23 functionPath: '_worker.js',24 next: vi.fn(),25 params: {},
8 unmodified lines
34 it('Should return 200 response', async () => {35 const request = new Request('http://localhost/api/foo')36 const env = {37 ASSETS: { fetch },38 TOKEN: 'HONOISCOOL',38 TOKEN: 'HONOISHOT',39 }40 const waitUntil = vi.fn()41 const passThroughOnException = vi.fn()42 const eventContext = createEventContext({
15 unmodified lines
58 { waitUntil, passThroughOnException }59 )60 expect(res.status).toBe(200)61 expect(await res.json()).toEqual({62 TOKEN: 'HONOISCOOL',62 TOKEN: 'HONOISHOT',63 requestURL: 'http://localhost/api/foo',64 })65 })66
182 unmodified lines
249 const assetsFetch = vi.fn().mockResolvedValue(new Response('foo.png'))250 const request = new Request('http://localhost/foo.png')251 const env = {252 ASSETS: { fetch: assetsFetch },253 TOKEN: 'HONOISCOOL',253 TOKEN: 'HONOISHOT',254 }255256 const eventContext = createEventContext({ request, env })257 const app = new Hono<Env>()
10 unmodified lines
268 const assetsFetch = vi.fn().mockResolvedValue(new Response(null, { status: 404 }))269 const request = new Request('http://localhost/foo.png')270 const env = {271 ASSETS: { fetch: assetsFetch },272 TOKEN: 'HONOISCOOL',272 TOKEN: 'HONOISHOT',273 }274275 const eventContext = createEventContext({ request, env })276 const app = new Hono<Env>()
8 unmodified lines
modified:src/adapter/service-worker/handler.test.ts-1 removed
modified:src/helper/css/common.case.test.tsx-1 removed
1/* eslint-disable quotes */1/** @jsxImportSource ../../jsx */2import type {3 Style as StyleComponent,4 css as cssHelper,
503 unmodified lines
modified:src/helper/css/common.ts+1 added-1 removed
49 unmodified lines
50}5152const cssStringReStr: string = [53 '"(?:(?:\\\\[\\s\\S]|[^"\\\\])*)"', // double quoted string54 // eslint-disable-next-line quotes5455 "'(?:(?:\\\\[\\s\\S]|[^'\\\\])*)'", // single quoted string56].join('|')57const minifyCssRe: RegExp = new RegExp(58 [
185 unmodified lines
modified:src/helper/html/index.test.ts+3 added-5 removed
2 unmodified lines
34describe('Tagged Template Literals', () => {5 it('Should escape special characters', () => {6 const name = 'John "Johnny" Smith'7 // eslint-disable-next-line quotes78 expect(html`<p>I'm ${name}.</p>`.toString()).toBe("<p>I'm John &quot;Johnny&quot; Smith.</p>")9 })1011 describe('Booleans, Null, and Undefined Are Ignored', () => {
22 unmodified lines
34 it('Should return Promise<string> when some variables contains Promise<string> in variables', async () => {35 const name = Promise.resolve('John "Johnny" Smith')36 const res = html`<p>I'm ${name}.</p>`37 expect(res).toBeInstanceOf(Promise)38 // eslint-disable-next-line quotes3839 expect((await res).toString()).toBe("<p>I'm John &quot;Johnny&quot; Smith.</p>")40 })4142 it('Should return raw value when some variables contains Promise<HtmlEscapedString> in variables', async () => {
15 unmodified lines
58 },59 ])60 const res = html`<p>I'm ${name}.</p>`61 expect(res).toBeInstanceOf(Promise)62 // eslint-disable-next-line quotes6263 expect((await res).toString()).toBe("<p>I'm Hono.</p>")64 expect(await resolveCallback(await res, HtmlEscapedCallbackPhase.Stringify, false, {})).toBe(65 // eslint-disable-next-line quotes65 "<p>I'm Hono!.</p>"66 )67 })68 })
2 unmodified lines
71describe('raw', () => {72 it('Should be marked as escaped.', () => {73 const name = 'John &quot;Johnny&quot; Smith'74 expect(html`<p>I'm ${raw(name)}.</p>`.toString()).toBe(76 // eslint-disable-next-line quotes75 "<p>I'm John &quot;Johnny&quot; Smith.</p>"76 )77 })78})
modified:src/jsx/dom/css.ts+1 added-2 removed
25 unmodified lines
26 for (let i = 0, len = rule.length; i < len; i++) {27 const char = rule[i]2829 // consume quote30 // eslint-disable-next-line quotes3031 if (char === "'" || char === '"') {32 const quote = char33 i++34 for (; i < len; i++) {
8 unmodified lines
43 continue44 }4546 // comments are removed from the rule in advance4747 if (char === '{') {48 depth++49 continue50 }
194 unmodified lines
modified:src/middleware/basic-auth/index.ts+1 added-1 removed
47 unmodified lines
48 * app.use(49 * '/auth/*',50 * basicAuth({51 * username: 'hono',52 * password: 'acoolproject',52 * password: 'ahotproject',53 * })54 * )55 *56 * app.get('/auth/page', (c) => {
72 unmodified lines
modified:src/middleware/bearer-auth/index.ts+1 added-1 removed
58 unmodified lines
59 * @example60 * ```ts61 * const app = new Hono()62 *63 * const token = 'honoiscool'63 * const token = 'honoishot'64 *65 * app.use('/api/*', bearerAuth({ token }))66 *67 * app.get('/api/page', (c) => {
92 unmodified lines
modified:src/middleware/body-limit/index.test.ts+3 added-3 removed
18 unmodified lines
1920describe('Body Limit Middleware', () => {21 let app: Hono2223 const exampleText = 'hono is so cool' // 15byte24 const exampleText2 = 'hono is so cool and cute' // 24byte23 const exampleText = 'hono is so hot' // 14byte24 const exampleText2 = 'hono is so hot and cute' // 23byte2526 beforeEach(() => {27 app = new Hono()28 app.use('*', bodyLimit({ maxSize: 15 }))28 app.use('*', bodyLimit({ maxSize: 14 }))29 app.get('/', (c) => c.text('index'))30 app.post('/body-limit-15byte', async (c) => {31 return c.text(await c.req.raw.text())32 })
101 unmodified lines
modified:src/middleware/context-storage/index.test.ts+2 added-2 removed
10 unmodified lines
11 const app = new Hono<Env>()1213 app.use(contextStorage())14 app.use(async (c, next) => {15 c.set('message', 'Hono is cool!!')15 c.set('message', 'Hono is hot!!')16 await next()17 })18 app.get('/', (c) => {19 return c.text(getMessage())
4 unmodified lines
24 }2526 it('Should get context', async () => {27 const res = await app.request('/')28 expect(await res.text()).toBe('Hono is cool!!')28 expect(await res.text()).toBe('Hono is hot!!')29 })30})
modified:src/middleware/context-storage/index.ts+1 added-1 removed
27 unmodified lines
28 *29 * app.use(contextStorage())30 *31 * app.use(async (c, next) => {32 * c.set('message', 'Hono is cool!!)32 * c.set('message', 'Hono is hot!!)33 * await next()34 * })35 *36 * app.get('/', async (c) => { c.text(getMessage()) })
19 unmodified lines
modified:src/middleware/etag/index.test.ts+16 added-16 removed
4 unmodified lines
5 it('Should return etag header', async () => {6 const app = new Hono()7 app.use('/etag/*', etag())8 app.get('/etag/abc', (c) => {9 return c.text('Hono is cool')9 return c.text('Hono is hot')10 })11 app.get('/etag/def', (c) => {12 return c.json({ message: 'Hono is cool' })12 return c.json({ message: 'Hono is hot' })13 })14 let res = await app.request('http://localhost/etag/abc')15 expect(res.headers.get('ETag')).not.toBeFalsy()16 expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')16 expect(res.headers.get('ETag')).toBe('"d104fafdb380655dab607c9bddc4d4982037afa1"')1718 res = await app.request('http://localhost/etag/def')19 expect(res.headers.get('ETag')).not.toBeFalsy()20 expect(res.headers.get('ETag')).toBe('"4515561204e8269cb4468d5b39288d8f2482dcfe"')20 expect(res.headers.get('ETag')).toBe('"67340414f1a52c4669a6cec71f0ae04532b29249"')21 })2223 it('Should return etag header with another algorithm', async () => {24 const app = new Hono()
9 unmodified lines
34 ),35 })36 )37 app.get('/etag/abc', (c) => {38 return c.text('Hono is cool')38 return c.text('Hono is hot')39 })40 app.get('/etag/def', (c) => {41 return c.json({ message: 'Hono is cool' })41 return c.json({ message: 'Hono is hot' })42 })43 let res = await app.request('http://localhost/etag/abc')44 expect(res.headers.get('ETag')).not.toBeFalsy()45 expect(res.headers.get('ETag')).toBe(46 '"ee7e84f92c4f54fec768123ac23003a6eb8437db95bcfbfc35db477af1ccb49e"'46 '"ed00834279b4fd5dcdc7ab6a5c9774de8afb2de30da2c8e0f17d0952839b5370"'47 )4849 res = await app.request('http://localhost/etag/def')50 expect(res.headers.get('ETag')).not.toBeFalsy()51 expect(res.headers.get('ETag')).toBe(52 '"6ae7438c67f07b60b2ab069dbce206b00d3528c690840a77e0222d37398a8547"'52 '"83b61a767db6e22afea68dd645b4d4597a06276c8ce7f895ad865cf4ab154ec4"'53 )54 })5556 it('Should return etag header - binary', async () => {
101 unmodified lines
158 it('Should return etag header - weak', async () => {159 const app = new Hono()160 app.use('/etag/*', etag({ weak: true }))161 app.get('/etag/abc', (c) => {162 return c.text('Hono is cool')162 return c.text('Hono is hot')163 })164165 const res = await app.request('http://localhost/etag/abc')166 expect(res.headers.get('ETag')).not.toBeFalsy()167 expect(res.headers.get('ETag')).toBe('W/"4e32298b1cb4edc595237405e5b696e105c2399a"')167 expect(res.headers.get('ETag')).toBe('W/"d104fafdb380655dab607c9bddc4d4982037afa1"')168 })169170 it('Should handle conditional GETs', async () => {171 const app = new Hono()
49 unmodified lines
221 it('Should not return duplicate etag header values', async () => {222 const app = new Hono()223 app.use('/etag/*', etag())224 app.use('/etag/*', etag())225 app.get('/etag/abc', (c) => c.text('Hono is cool'))225 app.get('/etag/abc', (c) => c.text('Hono is hot'))226227 const res = await app.request('http://localhost/etag/abc')228 expect(res.headers.get('ETag')).not.toBeFalsy()229 expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')229 expect(res.headers.get('ETag')).toBe('"d104fafdb380655dab607c9bddc4d4982037afa1"')230 })231232 it('Should not override ETag headers from upstream', async () => {233 const app = new Hono()
16 unmodified lines
250 retainedHeaders: ['x-message-retain', ...RETAINED_304_HEADERS],251 })252 )253 app.get('/etag', (c) => {254 return c.text('Hono is cool', 200, {254 return c.text('Hono is hot', 200, {255 'cache-control': cacheControl,256 'x-message-retain': message,257 'x-message': message,258 })259 })260 const res = await app.request('/etag', {261 headers: {262 'If-None-Match': '"4e32298b1cb4edc595237405e5b696e105c2399a"',262 'If-None-Match': '"d104fafdb380655dab607c9bddc4d4982037afa1"',263 },264 })265 expect(res.status).toBe(304)266 expect(res.headers.get('ETag')).not.toBeFalsy()267 expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')267 expect(res.headers.get('ETag')).toBe('"d104fafdb380655dab607c9bddc4d4982037afa1"')268 expect(res.headers.get('Cache-Control')).toBe(cacheControl)269 expect(res.headers.get('x-message-retain')).toBe(message)270 expect(res.headers.get('x-message')).toBeFalsy()271 })
15 unmodified lines
287288 it('Should not generate etag', async () => {289 const app = new Hono()290 app.use('/etag/*', etag())291 app.get('/etag/no-digest', (c) => c.text('Hono is cool'))291 app.get('/etag/no-digest', (c) => c.text('Hono is hot'))292 const res = await app.request('/etag/no-digest')293 expect(res.status).toBe(200)294 expect(res.headers.get('ETag')).toBeNull()295 })
2 unmodified lines
modified:src/middleware/etag/index.ts+1 added-1 removed
66 unmodified lines
67 * const app = new Hono()68 *69 * app.use('/etag/*', etag())70 * app.get('/etag/abc', (c) => {71 * return c.text('Hono is cool')71 * return c.text('Hono is hot')72 * })73 * ```74 */75export const etag = (options?: ETagOptions): MiddlewareHandler => {
41 unmodified lines
modified:src/middleware/request-id/index.test.ts+6 added-6 removed
18 unmodified lines
1920 it('Should return custom request id', async () => {21 const res = await app.request('http://localhost/requestId', {22 headers: {23 'X-Request-Id': 'hono-is-cool',23 'X-Request-Id': 'hono-is-hot',24 },25 })26 expect(res).not.toBeNull()27 expect(res.status).toBe(200)28 expect(res.headers.get('X-Request-Id')).toBe('hono-is-cool')29 expect(await res.text()).toBe('hono-is-cool')28 expect(res.headers.get('X-Request-Id')).toBe('hono-is-hot')29 expect(await res.text()).toBe('hono-is-hot')30 })3132 it('Should return random request id without using request header', async () => {33 const res = await app.request('http://localhost/requestId', {
101 unmodified lines
135136 it('Should return custom request id', async () => {137 const res = await app.request('http://localhost/requestId', {138 headers: {139 'Hono-Request-Id': 'hono-is-cool',139 'Hono-Request-Id': 'hono-is-hot',140 },141 })142 expect(res).not.toBeNull()143 expect(res.status).toBe(200)144 expect(res.headers.get('Hono-Request-Id')).toBe('hono-is-cool')145 expect(await res.text()).toBe('hono-is-cool')144 expect(res.headers.get('Hono-Request-Id')).toBe('hono-is-hot')145 expect(await res.text()).toBe('hono-is-hot')146 })147148 it('Should not return request id', async () => {149 const res = await app.request('http://localhost/emptyId')
6 unmodified lines
modified:src/middleware/secure-headers/index.test.ts+4 added-5 removed
1/* eslint-disable quotes */1import { Hono } from '../../hono'2import { poweredBy } from '../powered-by'3import { NONCE, secureHeaders } from '.'4import type { ContentSecurityPolicyOptionHandler } from '.'
192 unmodified lines
197 it('Remove X-Powered-By', async () => {198 const app = new Hono()199200 app.get('/test', secureHeaders(), poweredBy(), async (c) => {202 return c.text('Hono is cool')201 return c.text('Hono is hot')202 })203204 app.get(205 '/test2',
1 unmodified line
207 removePoweredBy: false,208 }),209 poweredBy(),210 async (c) => {212 return c.text('Hono is cool')211 return c.text('Hono is hot')212 }213 )214215 const res = await app.request('/test')216 const poweredby = res.headers.get('X-Powered-By')217 expect(poweredby).toEqual(null)219 expect(await res.text()).toEqual('Hono is cool')218 expect(await res.text()).toEqual('Hono is hot')219220 const res2 = await app.request('/test2')221 const poweredby2 = res2.headers.get('X-Powered-By')222 expect(poweredby2).toEqual('Hono')224 expect(await res2.text()).toEqual('Hono is cool')223 expect(await res2.text()).toEqual('Hono is hot')224 })225226 describe.each([227 { cspSettingName: 'contentSecurityPolicy', cspHeaderName: 'Content-Security-Policy' },
254 unmodified lines
modified:src/utils/accept.test.ts+1 added-1 removed
45 unmodified lines
46 const result = parseAccept(header)47 expect(result[0].params).toEqual({48 a: '1',49 b: '"2"',50 // eslint-disable-next-line quotes5051 c: "'3'",52 d: '"semi;colon"',53 e: '"nested"quoted""',54 })
104 unmodified lines
modified:src/context.ts+1 added-1 removed
573 unmodified lines
574 *575 * @example576 * ```ts577 * app.use('*', async (c, next) => {578 * c.set('message', 'Hono is cool!!')578 * c.set('message', 'Hono is hot!!')579 * await next()580 * })581 * ```582 */
283 unmodified lines