5htp-core 0.5.1-1 → 0.5.1-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.5.1-
|
|
4
|
+
"version": "0.5.1-2",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -7,6 +7,7 @@ import React from 'react';
|
|
|
7
7
|
import { VNode, RefObject,ComponentChild } from 'preact';
|
|
8
8
|
|
|
9
9
|
// Core
|
|
10
|
+
import { shouldOpenNewTab } from '@client/services/router/components/Link';
|
|
10
11
|
import { history } from '@client/services/router/request/history';
|
|
11
12
|
import useContext from '@/client/context';
|
|
12
13
|
|
|
@@ -19,7 +20,7 @@ export type Props = {
|
|
|
19
20
|
id?: string,
|
|
20
21
|
refElem?: RefObject<HTMLElement>,
|
|
21
22
|
|
|
22
|
-
icon?:
|
|
23
|
+
icon?: ComponentChild,
|
|
23
24
|
iconR?: ComponentChild,
|
|
24
25
|
|
|
25
26
|
prefix?: ComponentChild,
|
|
@@ -52,14 +53,9 @@ export type Props = {
|
|
|
52
53
|
hint?: string,
|
|
53
54
|
}) & (TButtonProps | TLinkProps)
|
|
54
55
|
|
|
55
|
-
export type TButtonProps =
|
|
56
|
-
|
|
57
|
-
}
|
|
56
|
+
export type TButtonProps = React.JSX.HTMLAttributes<HTMLButtonElement>
|
|
58
57
|
|
|
59
|
-
export type TLinkProps =
|
|
60
|
-
link: string, // Link
|
|
61
|
-
target?: string,
|
|
62
|
-
}
|
|
58
|
+
export type TLinkProps = React.JSX.HTMLAttributes<HTMLAnchorElement>
|
|
63
59
|
|
|
64
60
|
/*----------------------------------
|
|
65
61
|
- HELPERS
|
|
@@ -189,7 +185,7 @@ export default ({
|
|
|
189
185
|
props.href = props.link;
|
|
190
186
|
|
|
191
187
|
// External = open in new tab by default
|
|
192
|
-
if (props.href
|
|
188
|
+
if (shouldOpenNewTab( props.href, props.target ))
|
|
193
189
|
props.target = '_blank';
|
|
194
190
|
}
|
|
195
191
|
|
|
@@ -7,6 +7,14 @@ import React from 'react';
|
|
|
7
7
|
import type { ComponentChild } from 'preact';
|
|
8
8
|
import { history } from '../request/history';
|
|
9
9
|
|
|
10
|
+
export const shouldOpenNewTab = (url: string, target?: string) => url && (
|
|
11
|
+
target !== undefined
|
|
12
|
+
||
|
|
13
|
+
!['/', '#'].includes(url[0])
|
|
14
|
+
||
|
|
15
|
+
url.startsWith('//')
|
|
16
|
+
)
|
|
17
|
+
|
|
10
18
|
/*----------------------------------
|
|
11
19
|
- COMPONENT
|
|
12
20
|
----------------------------------*/
|
|
@@ -18,11 +26,7 @@ export const Link = ({ to, ...props }: {
|
|
|
18
26
|
className?: string
|
|
19
27
|
} & React.HTMLProps<HTMLAnchorElement>) => {
|
|
20
28
|
|
|
21
|
-
const openNewTab = to
|
|
22
|
-
!['/', '#'].includes(to[0])
|
|
23
|
-
||
|
|
24
|
-
to.startsWith('//')
|
|
25
|
-
);
|
|
29
|
+
const openNewTab = shouldOpenNewTab(to, props.target);
|
|
26
30
|
|
|
27
31
|
// External = open in new tab by default
|
|
28
32
|
if (openNewTab)
|
|
@@ -11,7 +11,7 @@ import type { TBasicUser } from '@server/services/auth';
|
|
|
11
11
|
|
|
12
12
|
export type TListeErreursSaisie<TClesDonnees extends string = string> = {[champ in TClesDonnees]: string[]}
|
|
13
13
|
|
|
14
|
-
type TJsonError = {
|
|
14
|
+
export type TJsonError = {
|
|
15
15
|
code: number,
|
|
16
16
|
origin?: string,
|
|
17
17
|
message: string,
|
|
@@ -49,7 +49,8 @@ export type Config = {
|
|
|
49
49
|
images?: string[],
|
|
50
50
|
scripts: string[],
|
|
51
51
|
},
|
|
52
|
-
cors?: CorsOptions
|
|
52
|
+
cors?: CorsOptions,
|
|
53
|
+
helmet?: Parameters<typeof helmet>[0]
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export type Hooks = {
|
|
@@ -100,7 +101,7 @@ export default class HttpServer {
|
|
|
100
101
|
// Config
|
|
101
102
|
routes.set('trust proxy', 1); // Indique qu'on est sous le proxy apache
|
|
102
103
|
// Diverses protections (dont le disable x-powered-by)
|
|
103
|
-
routes.use(helmet());
|
|
104
|
+
routes.use( helmet(this.config.helmet) );
|
|
104
105
|
|
|
105
106
|
/*----------------------------------
|
|
106
107
|
- FICHIERS STATIQUES
|