Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
angular-cookies
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Custom Issue Tracker
Custom Issue Tracker
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angularjs
angular-cookies
Commits
0a403424
Commit
0a403424
authored
Mar 21, 2021
by
bingchuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev] version 1.8.2
parent
aa8ce930
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
218 additions
and
287 deletions
+218
-287
angular-cookies.js
angular-cookies.js
+216
-285
bower.json
bower.json
+2
-2
No files found.
angular-cookies.js
View file @
0a403424
/**
* @license AngularJS v1.
5.7
* (c) 2010-20
16 Google, Inc
. http://angularjs.org
* @license AngularJS v1.
8.2
* (c) 2010-20
20 Google LLC
. http://angularjs.org
* License: MIT
*/
(
function
(
window
,
angular
)
{
'use strict'
;
/**
/**
* @ngdoc module
* @name ngCookies
* @description
*
* # ngCookies
*
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
*
*
* <div doc-module-components="ngCookies"></div>
*
* See {@link ngCookies.$cookies `$cookies`} for usage.
*/
angular
.
module
(
'ngCookies'
,
[
'ng'
]).
angular
.
module
(
'ngCookies'
,
[
'ng'
]).
info
({
angularVersion
:
'1.8.2'
}).
/**
* @ngdoc provider
* @name $cookiesProvider
* @description
* Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service.
* */
provider
(
'$cookies'
,
[
function
$CookiesProvider
()
{
provider
(
'$cookies'
,
[
/** @this */
function
$CookiesProvider
()
{
/**
* @ngdoc property
* @name $cookiesProvider#defaults
...
...
@@ -47,10 +43,24 @@ angular.module('ngCookies', ['ng']).
* or a Date object indicating the exact date/time this cookie will expire.
* - **secure** - `{boolean}` - If `true`, then the cookie will only be available through a
* secured connection.
* - **samesite** - `{string}` - prevents the browser from sending the cookie along with cross-site requests.
* Accepts the values `lax` and `strict`. See the [OWASP Wiki](https://www.owasp.org/index.php/SameSite)
* for more info. Note that as of May 2018, not all browsers support `SameSite`,
* so it cannot be used as a single measure against Cross-Site-Request-Forgery (CSRF) attacks.
*
* Note: By default, the address that appears in your `<base>` tag will be used as the path.
* This is important so that cookies will be visible for all routes when html5mode is enabled.
*
* @example
*
* ```js
* angular.module('cookiesProviderExample', ['ngCookies'])
* .config(['$cookiesProvider', function($cookiesProvider) {
* // Setting default options
* $cookiesProvider.defaults.domain = 'foo.com';
* $cookiesProvider.defaults.secure = true;
* }]);
* ```
**/
var
defaults
=
this
.
defaults
=
{};
...
...
@@ -66,7 +76,7 @@ angular.module('ngCookies', ['ng']).
* Provides read/write access to browser's cookies.
*
* <div class="alert alert-info">
* Up until Angular
1.3, `$cookies` exposed properties that represented the
* Up until AngularJS
1.3, `$cookies` exposed properties that represented the
* current browser cookie values. In version 1.4, this behavior has changed, and
* `$cookies` now provides a standard api of getters, setters etc.
* </div>
...
...
@@ -179,87 +189,7 @@ angular.module('ngCookies', ['ng']).
}];
}]);
angular
.
module
(
'ngCookies'
).
/**
* @ngdoc service
* @name $cookieStore
* @deprecated
* @requires $cookies
*
* @description
* Provides a key-value (string-object) storage, that is backed by session cookies.
* Objects put or retrieved from this storage are automatically serialized or
* deserialized by angular's toJson/fromJson.
*
* Requires the {@link ngCookies `ngCookies`} module to be installed.
*
* <div class="alert alert-danger">
* **Note:** The $cookieStore service is **deprecated**.
* Please use the {@link ngCookies.$cookies `$cookies`} service instead.
* </div>
*
* @example
*
* ```js
* angular.module('cookieStoreExample', ['ngCookies'])
* .controller('ExampleController', ['$cookieStore', function($cookieStore) {
* // Put cookie
* $cookieStore.put('myFavorite','oatmeal');
* // Get cookie
* var favoriteCookie = $cookieStore.get('myFavorite');
* // Removing a cookie
* $cookieStore.remove('myFavorite');
* }]);
* ```
*/
factory
(
'$cookieStore'
,
[
'$cookies'
,
function
(
$cookies
)
{
return
{
/**
* @ngdoc method
* @name $cookieStore#get
*
* @description
* Returns the value of given cookie key
*
* @param {string} key Id to use for lookup.
* @returns {Object} Deserialized cookie value, undefined if the cookie does not exist.
*/
get
:
function
(
key
)
{
return
$cookies
.
getObject
(
key
);
},
/**
* @ngdoc method
* @name $cookieStore#put
*
* @description
* Sets a value for given cookie key
*
* @param {string} key Id for the `value`.
* @param {Object} value Value to be stored.
*/
put
:
function
(
key
,
value
)
{
$cookies
.
putObject
(
key
,
value
);
},
/**
* @ngdoc method
* @name $cookieStore#remove
*
* @description
* Remove given cookie
*
* @param {string} key Id of the key-value pair to delete.
*/
remove
:
function
(
key
)
{
$cookies
.
remove
(
key
);
}
};
}]);
/**
* @name $$cookieWriter
* @requires $document
*
...
...
@@ -270,7 +200,7 @@ angular.module('ngCookies').
* @param {string=} value Cookie value (if undefined, cookie will be deleted)
* @param {Object=} options Object with options that need to be stored for the cookie.
*/
function
$$CookieWriter
(
$document
,
$log
,
$browser
)
{
function
$$CookieWriter
(
$document
,
$log
,
$browser
)
{
var
cookiePath
=
$browser
.
baseHref
();
var
rawDocument
=
$document
[
0
];
...
...
@@ -292,6 +222,7 @@ function $$CookieWriter($document, $log, $browser) {
str
+=
options
.
domain
?
';domain='
+
options
.
domain
:
''
;
str
+=
expires
?
';expires='
+
expires
.
toUTCString
()
:
''
;
str
+=
options
.
secure
?
';secure'
:
''
;
str
+=
options
.
samesite
?
';samesite='
+
options
.
samesite
:
''
;
// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
// - 300 cookies
...
...
@@ -299,9 +230,9 @@ function $$CookieWriter($document, $log, $browser) {
// - 4096 bytes per cookie
var
cookieLength
=
str
.
length
+
1
;
if
(
cookieLength
>
4096
)
{
$log
.
warn
(
"Cookie '"
+
name
+
"' possibly not set or overflowed because it was too large ("
+
cookieLength
+
" > 4096 bytes)!"
);
$log
.
warn
(
'Cookie
\'
'
+
name
+
'
\'
possibly not set or overflowed because it was too large ('
+
cookieLength
+
' > 4096 bytes)!'
);
}
return
str
;
...
...
@@ -310,13 +241,13 @@ function $$CookieWriter($document, $log, $browser) {
return
function
(
name
,
value
,
options
)
{
rawDocument
.
cookie
=
buildCookieString
(
name
,
value
,
options
);
};
}
}
$$CookieWriter
.
$inject
=
[
'$document'
,
'$log'
,
'$browser'
];
$$CookieWriter
.
$inject
=
[
'$document'
,
'$log'
,
'$browser'
];
angular
.
module
(
'ngCookies'
).
provider
(
'$$cookieWriter'
,
function
$$CookieWriterProvider
()
{
angular
.
module
(
'ngCookies'
).
provider
(
'$$cookieWriter'
,
/** @this */
function
$$CookieWriterProvider
()
{
this
.
$get
=
$$CookieWriter
;
});
});
})(
window
,
window
.
angular
);
bower.json
View file @
0a403424
{
"name"
:
"angular-cookies"
,
"version"
:
"1.
5.7
"
,
"version"
:
"1.
8.2
"
,
"license"
:
"MIT"
,
"main"
:
"./angular-cookies.js"
,
"ignore"
:
[],
"dependencies"
:
{
"angular"
:
"1.
5.7
"
"angular"
:
"1.
8.2
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment