Skip to content

Commit

Permalink
fix #177
Browse files Browse the repository at this point in the history
  • Loading branch information
Diablohu committed Sep 26, 2019
1 parent 0cc9136 commit a316eab
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ module.exports = {
__KOOT_PROJECT_CONFIG_PATHNAME__: 'readonly'
},
rules: {
'no-console': 0
// 'no-console': 0
}
};
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

- 更新依赖包 minor 和 patch 版本号

**koot**

- 错误修正
- `cookiesToStore``'all'` 时,部分带有 `=` 的值处理错误 ([#177](https://github.com/cmux/koot/issues/177))

**koot-boilerplate**

- 为日文添加更合适的字体
Expand Down
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

`Pathname` 类型表示到对应文件的路径名,支持绝对路径和相对路径,相对路径必须以 `.` 开头。

`Pathname:[type]` 类型表示到对应文件的路径名,对应的文件必须是 `.js` `.jsx``.mjs` 文件,同时输出对应类型的结果。如 `Pathname:Object` 表示对应到 js 文件,该文件需要输出 `Object` 类型。
`Pathname:[type]` 类型表示到对应文件的路径名,对应的文件必须是 `.js` `.jsx` `.mjs` `.cjs` `.ts` `.tsx` 文件,同时输出对应类型的结果。如 `Pathname:Object` 表示对应到 js 文件,该文件需要输出 `Object` 类型。

**简单配置示例**

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"cheerio": "^1.0.0-rc.3",
"crlf": "^1.1.1",
"eslint": "^6.4.0",
"eslint-config-koot": "^1.4.0",
"eslint-config-koot": "^1.5.0",
"fs-extra": "^8.1.0",
"husky": "^3.0.5",
"inquirer": "^7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const beforeRouterMatch = async ({ store, ctx, syncCookie, callback }) => {
theCookies.split(';').forEach(str => {
const crumbs = str.split('=');
if (crumbs.length > 1) {
data[crumbs[0].trim()] = crumbs[1].trim();
const [key, ...values] = crumbs;
data[key.trim()] = values.join('=').trim();
}
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/koot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@babel/preset-typescript": "^7.6.0",
"@babel/register": "^7.6.2",
"@hot-loader/react-dom": "^16.9.0",
"@types/node": "^12.7.7",
"@types/node": "^12.7.8",
"@types/react": "^16.9.3",
"@types/react-dom": "^16.9.1",
"@types/react-redux": "^7.1.3",
Expand Down
12 changes: 7 additions & 5 deletions test/cases/react-isomorphic/need-in-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* **cookiesToStore**
* - 默认: `true`
* - 二号: `"all"`
* - 三号: `['kootTest2']`
* - 三号: `['kootTest2', 'kootTest3']`
* - 0.6版配置: `false`
*
* **sessionStore**
Expand Down Expand Up @@ -399,7 +399,7 @@ const doPuppeteerTest = async (port, dist, settings = {}) => {
document.querySelector('a[href$="/static"]').click();
})
]).catch(e => (err = e));
if (err) console.log(err);
if (err) console.error(err);
expect(typeof err).toBe('undefined');
}

Expand Down Expand Up @@ -1054,7 +1054,8 @@ const doPuppeteerTest = async (port, dist, settings = {}) => {
const { cookie: result } = SSRStateServer;
const validResult = {
kootTest: 'valueForKootTest',
kootTest2: 'valueForKootTest2'
kootTest2: 'valueForKootTest2',
kootTest3: 'koot=koot==koot==='
};

if (cookiesToStore === true) {
Expand Down Expand Up @@ -1137,7 +1138,7 @@ const doPuppeteerTest = async (port, dist, settings = {}) => {

// 测试: 没有失败的请求
if (failedResponse.length) {
console.log(
console.error(
'failedResponse',
failedResponse.map(res => ({
status: res.status(),
Expand Down Expand Up @@ -1178,6 +1179,7 @@ const afterTest = async (cwd, title) => {
// 移除临时项目配置文件
await removeTempProjectConfig(cwd);

// eslint-disable-next-line no-console
console.log(
chalk.green('√ ') +
chalk.green(`${(Date.now() - lastTime) / 1000}s `) +
Expand Down Expand Up @@ -1413,7 +1415,7 @@ describe('测试: React 同构项目', () => {
'koot.config.no-bundles-keep.js',
'isomorphic-no_bundles_keep',
{
cookiesToStore: ['kootTest2']
cookiesToStore: ['kootTest2', 'kootTest3']
}
);

Expand Down
2 changes: 1 addition & 1 deletion test/projects/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@babel/preset-typescript": "^7.6.0",
"@babel/register": "^7.6.2",
"@hot-loader/react-dom": "^16.9.0",
"@types/node": "^12.7.7",
"@types/node": "^12.7.8",
"@types/react": "^16.9.3",
"@types/react-dom": "^16.9.1",
"@types/react-redux": "^7.1.3",
Expand Down
2 changes: 1 addition & 1 deletion test/projects/standard/koot.config.no-bundles-keep.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = Object.assign({}, baseConfig, {
return;
},

cookiesToStore: ['kootTest2'],
cookiesToStore: ['kootTest2', 'kootTest3'],
sessionStore: {
app: {
name: true
Expand Down
2 changes: 1 addition & 1 deletion test/projects/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@babel/preset-typescript": "^7.6.0",
"@babel/register": "^7.6.2",
"@hot-loader/react-dom": "^16.9.0",
"@types/node": "^12.7.7",
"@types/node": "^12.7.8",
"@types/react": "^16.9.3",
"@types/react-dom": "^16.9.1",
"@types/react-redux": "^7.1.3",
Expand Down
1 change: 1 addition & 0 deletions test/projects/standard/server/lifecycle/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default async app => {
app.use(async (ctx, next) => {
ctx.cookies.set('kootTest', 'valueForKootTest', { maxAge: 0 });
ctx.cookies.set('kootTest2', 'valueForKootTest2', { maxAge: 0 });
ctx.cookies.set('kootTest3', 'koot=koot==koot===', { maxAge: 0 });
return await next();
});
serverRouter(app);
Expand Down

0 comments on commit a316eab

Please sign in to comment.