Skip to content

Commit

Permalink
refactor: upgrade to v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
myConsciousness committed May 18, 2022
1 parent a154498 commit 4aeb66d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
21 changes: 13 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
# Release Note

## 1.0.4
## v1.1.0

- Added `+` operator and you can combine `SweetCookieJar`s. ([#4](https://github.com/myConsciousness/sweet-cookie-jar/pull/4))
- Fixed regex for splitting cookies. ([#2](https://github.com/myConsciousness/sweet-cookie-jar/pull/2))

## v1.0.4

- Fixed some documents.

## 1.0.3
## v1.0.3

- Supported more multiple platforms.

## 1.0.2
## v1.0.2

- Improved documents.

## 1.0.1
## v1.0.1

- Improved minor features.

## 1.0.0
## v1.0.0

- Just upgrade version to `1.0.0`.

## 0.0.3
## v0.0.3

- Fixed minor features.

## 0.0.2
## v0.0.2

- Fixed so that this library can be used from web applications.

## 0.0.1
## v0.0.1

- First release!
2 changes: 1 addition & 1 deletion lib/src/sweet_cookie_jar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ abstract class SweetCookieJar {
/// Returns true if this cookie jar contains cookie linked to [name], otherwise false.
bool containsName({required String name});

/// Combines two [SweetCookieJar].
/// Combines two [SweetCookieJar]s.
SweetCookieJar operator +(SweetCookieJar cookieJar);
}
17 changes: 10 additions & 7 deletions lib/src/sweet_cookie_jar_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ class SweetCookieJarImpl implements SweetCookieJar {
return;
}

final cookiesSplit = RegExp(
r"""(?<!expires=\w{3}|"|')\s*,\s*(?!"|')""",
caseSensitive: false,
);
for (final cookie in setCookie.split(cookiesSplit)) {
for (final cookie in setCookie.split(_regexSplitSetCookies)) {
_cookies.add(Cookie.fromSetCookieValue(cookie));
}

_rawData = setCookie;
}

/// The regex pattern for splitting the set-cookie header.
static final _regexSplitSetCookies = RegExp(
r"""(?<!expires=\w{3}|"|')\s*,\s*(?!"|')""",
caseSensitive: false,
);

/// The cookies
final List<Cookie> _cookies = [];

Expand Down Expand Up @@ -107,12 +109,13 @@ class SweetCookieJarImpl implements SweetCookieJar {

@override
SweetCookieJar operator +(SweetCookieJar cookieJar) {
final _response = Response.bytes(
final newResponse = Response.bytes(
[],
200,
headers: {'set-cookie': "$rawData,${cookieJar.rawData}"},
);
return SweetCookieJarImpl.from(response: _response);

return SweetCookieJarImpl.from(response: newResponse);
}

String _getSetCookie({required Response response}) {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sweet_cookie_jar
description: A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.
version: 1.0.4
version: 1.1.0
homepage: https://github.com/myConsciousness/sweet-cookie-jar

environment:
Expand All @@ -13,5 +13,5 @@ dependencies:

dev_dependencies:
flutter_lints: ^1.0.0
import_sorter: ^4.6.0
test: ^1.16.0
import_sorter: ^4.6.0

0 comments on commit 4aeb66d

Please sign in to comment.