5htp-core 0.2.6-5 → 0.2.6-6
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.2.6-
|
|
4
|
+
"version": "0.2.6-6",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,7 +55,8 @@ export default ({ service: router }: { service: Router }) => {
|
|
|
55
55
|
|
|
56
56
|
// Page not found: Directly load with the browser
|
|
57
57
|
if (newpage === undefined) {
|
|
58
|
-
window.location.replace(request.
|
|
58
|
+
window.location.replace(request.url);
|
|
59
|
+
console.error("not found");
|
|
59
60
|
return;
|
|
60
61
|
// Unable to load (no connection, server error, ....)
|
|
61
62
|
} else if (newpage === null) {
|
|
@@ -86,7 +87,7 @@ export default ({ service: router }: { service: Router }) => {
|
|
|
86
87
|
// But when we call setLayout, the style of the previous layout are still oaded and applied
|
|
87
88
|
// Find a way to unload the previous layout / page resources before to load the new one
|
|
88
89
|
console.log(LogPrefix, `Changing layout. Before:`, curLayout, 'New layout:', newLayout);
|
|
89
|
-
window.location.replace(request.
|
|
90
|
+
window.location.replace(request.url);
|
|
90
91
|
return pages;
|
|
91
92
|
|
|
92
93
|
context.app.setLayout(newLayout);
|
|
@@ -27,6 +27,8 @@ export default class ClientRequest<TRouter extends ClientRouter = ClientRouter>
|
|
|
27
27
|
|
|
28
28
|
public api: ApiClient;
|
|
29
29
|
public response?: ClientResponse<TRouter>;
|
|
30
|
+
|
|
31
|
+
public url: string;
|
|
30
32
|
public hash?: string;
|
|
31
33
|
|
|
32
34
|
public constructor(
|
|
@@ -38,8 +40,16 @@ export default class ClientRequest<TRouter extends ClientRouter = ClientRouter>
|
|
|
38
40
|
super(location.pathname);
|
|
39
41
|
|
|
40
42
|
this.host = window.location.host;
|
|
43
|
+
this.url = window.location.protocol + '//' + window.location.host + this.path;
|
|
41
44
|
this.hash = location.hash;
|
|
42
45
|
|
|
46
|
+
// Extract search params
|
|
47
|
+
if (location.search) {
|
|
48
|
+
this.url += location.search;
|
|
49
|
+
this.data = Object.fromEntries( new URLSearchParams( location.search ));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Request services
|
|
43
53
|
this.api = new ApiClient(this.app, this);
|
|
44
54
|
}
|
|
45
55
|
|
|
@@ -43,6 +43,12 @@ export type Config = {
|
|
|
43
43
|
upload: {
|
|
44
44
|
maxSize: string // Expression package bytes
|
|
45
45
|
},
|
|
46
|
+
csp: {
|
|
47
|
+
default?: string[],
|
|
48
|
+
styles?: string[],
|
|
49
|
+
images?: string[],
|
|
50
|
+
scripts: string[],
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
export type Hooks = {
|
|
@@ -193,9 +199,7 @@ export default class HttpServer extends Service<Config, Hooks, Application> {
|
|
|
193
199
|
routes.use( csp.expressCspHeader({
|
|
194
200
|
directives: {
|
|
195
201
|
'script-src': [csp.INLINE, csp.SELF,
|
|
196
|
-
|
|
197
|
-
"https://www.googletagmanager.com/gtag/js",
|
|
198
|
-
"https://cdn.jsdelivr.net"
|
|
202
|
+
...this.config.csp.scripts
|
|
199
203
|
]
|
|
200
204
|
}
|
|
201
205
|
}));
|