-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support function to set domain #38
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #38 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 203 207 +4
Branches 51 52 +1
=========================================
+ Hits 203 207 +4
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
[skip ci] ## [2.7.0](v2.6.1...v2.7.0) (2023-08-04) ### Features * support function to set domain ([#38](#38)) ([c73b415](c73b415))
🎉 This PR is included in version 2.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@@ -28,7 +28,11 @@ class Cookie { | |||
this.value = value || ''; | |||
this.attrs = mergeDefaultAttrs(attrs); | |||
assert(!this.attrs.path || fieldContentRegExp.test(this.attrs.path), 'argument option path is invalid'); | |||
assert(!this.attrs.domain || fieldContentRegExp.test(this.attrs.domain), 'argument option domain is invalid'); | |||
assert(!this.attrs.domain || typeof this.attrs.domain === 'string' || typeof this.attrs.domain === 'function', 'argument option domain is invalid'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodejs.AssertionError: argument option domain is invalid
at new Cookie (/home/admin/app/node_modules/_egg-cookies@2.7.0@egg-cookies/lib/cookie.js:35:5)
at Cookies.set (/home/admin/app/node_modules/_egg-cookies@2.7.0@egg-cookies/lib/cookies.js:124:20)
at updateCookie (/home/admin/app/node_modules/_koa-locales@1.12.0@koa-locales/index.js:254:17)
at Object.app.context.__getLocale (/home/admin/app/node_modules/_koa-locales@1.12.0@koa-locales/index.js:224:7)
at Object.get locale [as locale] (/home/admin/app/node_modules/_egg-i18n@2.1.1@egg-i18n/app/extend/context.js:10:17)
closes #38 (comment) remove debug deps
[skip ci] ## [2.7.1](v2.7.0...v2.7.1) (2023-08-04) ### Bug Fixes * domain can be empty string ([#39](#39)) ([0b285e1](0b285e1)), closes [/github.com//pull/38#discussion_r1284672929](https://github.com/eggjs//github.com/eggjs/egg-cookies/pull/38/issues/discussion_r1284672929)
Checklist
npm test
passesAffected core subsystem(s)
Description of change
由于 set-cookies 时无法设置多 domain
支持 domain 传入函数,当有多个不同域名访问时,可由用户自定义动态设置 domain,示例如下