manner.js 0.0.2 → 0.0.3
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 +1 -1
- package/packages/client/dist/32.index.js +1 -0
- package/packages/client/dist/index.js +2 -0
- package/packages/client/dist/index.js.LICENSE.txt +9 -0
- package/packages/client/postcss.config.js +6 -0
- package/packages/client/src/class/Dimmer.js +19 -0
- package/packages/client/src/class/Emitter.js +36 -0
- package/packages/client/src/component/Router/index.js +88 -0
- package/packages/client/src/component/Router/index.module.css +2 -0
- package/packages/client/src/component/UpdateConfirm/index.js +61 -0
- package/packages/client/src/component/UpdateConfirm/index.module.css +40 -0
- package/packages/client/src/component/WebApp/index.js +42 -0
- package/packages/client/src/index.js +6 -0
- package/packages/client/src/lib/checkUpdate.js +9 -0
- package/packages/client/src/lib/clearCookie.js +16 -0
- package/packages/client/src/lib/filterNamespace.js +9 -0
- package/packages/client/src/lib/formateLocation.js +8 -0
- package/packages/client/src/lib/readCookie.js +32 -0
- package/packages/client/src/lib/setCookie.js +19 -0
- package/packages/client/src/lib/template/locationTemplate/index.js +14 -0
- package/packages/client/src/lib/template/locationTemplate/index.module.css +4 -0
- package/packages/client/src/obj/location.js +3 -0
- package/packages/client/src/page/NotFound/index.js +21 -0
- package/packages/client/src/page/NotFound/index.module.css +28 -0
- package/packages/client/webpack.config.dev.js +62 -0
- package/packages/client/webpack.config.pro.js +47 -0
- package/packages/server/dist/class/CommonHttp.js +70 -0
- package/packages/server/dist/index.js +12 -0
- package/packages/server/dist/lib/cacheOutput.js +41 -0
- package/packages/server/dist/lib/compressOutput.js +44 -0
- package/packages/server/dist/lib/filterNamespace.js +17 -0
- package/packages/server/dist/lib/formateHttpDate.js +11 -0
- package/packages/server/dist/lib/formateHttpKey.js +11 -0
- package/packages/server/dist/lib/parseHttpDate.js +9 -0
- package/packages/server/dist/lib/parseOption.js +70 -0
- package/packages/server/dist/lib/readCookie.js +27 -0
- package/packages/server/src/class/CommonHttp.js +64 -0
- package/packages/server/src/index.js +2 -0
- package/packages/server/src/lib/cacheOutput.js +36 -0
- package/packages/server/src/lib/compressOutput.js +40 -0
- package/packages/server/src/lib/filterNamespace.js +11 -0
- package/packages/server/src/lib/formateHttpDate.js +5 -0
- package/packages/server/src/lib/formateHttpKey.js +5 -0
- package/packages/server/src/lib/parseHttpDate.js +3 -0
- package/packages/server/src/lib/parseOption.js +66 -0
- package/packages/server/src/lib/readCookie.js +21 -0
- package/packages/server/test/CommonHttp.test.js +18 -0
- package/packages/server/test/parseOption.test.js +9 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default function readCookie(cookie) {
|
|
2
|
+
const cookies = {};
|
|
3
|
+
if (typeof cookie === 'string') {
|
|
4
|
+
cookie.split(';').forEach((i) => {
|
|
5
|
+
const [key, value] = i.split('=');
|
|
6
|
+
cookies[key.trim()] = value;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const namespaces = {};
|
|
10
|
+
Object.keys(cookies).forEach((k) => {
|
|
11
|
+
const result = k.split('_');
|
|
12
|
+
if (result.length === 2) {
|
|
13
|
+
const [namespace, key] = result;
|
|
14
|
+
if (namespaces[namespace] === undefined) {
|
|
15
|
+
namespaces[namespace] = {};
|
|
16
|
+
}
|
|
17
|
+
namespaces[namespace][key] = cookies[k];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return namespaces;
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, test, } from '@jest/globals';
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import fetch from 'node-fetch';
|
|
4
|
+
import CommonHttp from '~/class/CommonHttp';
|
|
5
|
+
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
http.createServer(async (req, res) => {
|
|
8
|
+
const commonHttp = new CommonHttp({});
|
|
9
|
+
await commonHttp.process(req, res);
|
|
10
|
+
res.end('result')
|
|
11
|
+
}).listen(80);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('[class] CommonHttp', async () => {
|
|
15
|
+
const response = await fetch('http://localhost');
|
|
16
|
+
const body = await response.text();
|
|
17
|
+
expect(JSON.stringify(body)).toMatch('\"result\"');
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { describe, expect, test, } from '@jest/globals';
|
|
2
|
+
import parseOption from '~/lib/parseOption';
|
|
3
|
+
|
|
4
|
+
describe('[lib] parseOption', () => {
|
|
5
|
+
test('command line option should parse correct.', () => {
|
|
6
|
+
expect(parseOption('-t', 'type', '--type', 'type', '--detail-type', 'type')
|
|
7
|
+
).toEqual({ 't': 'type', 'type': 'type', 'detailType': 'type' });
|
|
8
|
+
});
|
|
9
|
+
});
|