mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 11:51:01 +01:00
Merge branch 'main' into next
This commit is contained in:
commit
963b94e67e
@ -1,5 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { html } from '../helper/html/index.ts'
|
||||
import { Hono } from '../hono.ts'
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { jsx, memo, Fragment } from './index.ts'
|
||||
|
||||
interface SiteData {
|
||||
@ -364,6 +366,16 @@ describe('Fragment', () => {
|
||||
expect(template.toString()).toBe('<p>1</p><p>2</p>')
|
||||
})
|
||||
|
||||
it('Should render children - with `Fragment`', () => {
|
||||
const template = (
|
||||
<Fragment>
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
</Fragment>
|
||||
)
|
||||
expect(template.toString()).toBe('<p>1</p><p>2</p>')
|
||||
})
|
||||
|
||||
it('Should render nothing for empty Fragment', () => {
|
||||
const template = <></>
|
||||
expect(template.toString()).toBe('')
|
||||
|
@ -235,6 +235,6 @@ export const memo = <T>(
|
||||
}) as FC<T>
|
||||
}
|
||||
|
||||
export const Fragment = (props: { key?: string; children?: Child[] }): JSXNode => {
|
||||
return new JSXFragmentNode('', {}, props.children || [])
|
||||
export const Fragment = (props: { key?: string; children?: Child[] }): HtmlEscapedString => {
|
||||
return new JSXFragmentNode('', {}, props.children || []) as never
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ export const bufferToString = (buffer: ArrayBuffer): string => {
|
||||
return buffer
|
||||
}
|
||||
|
||||
const _decodeURIComponent = decodeURIComponent
|
||||
const _decodeURIComponent = (str: string) => decodeURIComponent(str.replace(/\+/g, ' '))
|
||||
|
||||
export const bufferToFormData = (arrayBuffer: ArrayBuffer, contentType: string) => {
|
||||
const decoder = new TextDecoder('utf-8')
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hono",
|
||||
"version": "3.5.7",
|
||||
"version": "3.5.8",
|
||||
"description": "Ultrafast web framework for the Edges",
|
||||
"main": "dist/cjs/index.js",
|
||||
"type": "module",
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { html } from '../helper/html'
|
||||
import { Hono } from '../hono'
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { jsx, memo, Fragment } from './index'
|
||||
|
||||
interface SiteData {
|
||||
@ -364,6 +366,16 @@ describe('Fragment', () => {
|
||||
expect(template.toString()).toBe('<p>1</p><p>2</p>')
|
||||
})
|
||||
|
||||
it('Should render children - with `Fragment`', () => {
|
||||
const template = (
|
||||
<Fragment>
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
</Fragment>
|
||||
)
|
||||
expect(template.toString()).toBe('<p>1</p><p>2</p>')
|
||||
})
|
||||
|
||||
it('Should render nothing for empty Fragment', () => {
|
||||
const template = <></>
|
||||
expect(template.toString()).toBe('')
|
||||
|
@ -235,6 +235,6 @@ export const memo = <T>(
|
||||
}) as FC<T>
|
||||
}
|
||||
|
||||
export const Fragment = (props: { key?: string; children?: Child[] }): JSXNode => {
|
||||
return new JSXFragmentNode('', {}, props.children || [])
|
||||
export const Fragment = (props: { key?: string; children?: Child[] }): HtmlEscapedString => {
|
||||
return new JSXFragmentNode('', {}, props.children || []) as never
|
||||
}
|
||||
|
@ -68,12 +68,15 @@ describe('bufferToFormData', () => {
|
||||
|
||||
it('Should parse application/x-www-form-urlencoded from ArrayBuffer', () => {
|
||||
const encoder = new TextEncoder()
|
||||
const testData = 'key1=value1&key2=value2'
|
||||
const searchParams = new URLSearchParams()
|
||||
searchParams.append('id', '123')
|
||||
searchParams.append('title', 'Good title')
|
||||
const testData = searchParams.toString()
|
||||
const arrayBuffer = encoder.encode(testData).buffer
|
||||
|
||||
const result = bufferToFormData(arrayBuffer, 'application/x-www-form-urlencoded')
|
||||
|
||||
expect(result.get('key1')).toBe('value1')
|
||||
expect(result.get('key2')).toBe('value2')
|
||||
expect(result.get('id')).toBe('123')
|
||||
expect(result.get('title')).toBe('Good title')
|
||||
})
|
||||
})
|
||||
|
@ -48,7 +48,7 @@ export const bufferToString = (buffer: ArrayBuffer): string => {
|
||||
return buffer
|
||||
}
|
||||
|
||||
const _decodeURIComponent = decodeURIComponent
|
||||
const _decodeURIComponent = (str: string) => decodeURIComponent(str.replace(/\+/g, ' '))
|
||||
|
||||
export const bufferToFormData = (arrayBuffer: ArrayBuffer, contentType: string) => {
|
||||
const decoder = new TextDecoder('utf-8')
|
||||
|
Loading…
Reference in New Issue
Block a user