Skip to content

Commit 6493d25

Browse files
committed
- extend cookie api to accept an object for cookie options
- upgrade modules to fix vulnerabilities - bump version
1 parent 2c80130 commit 6493d25

File tree

15 files changed

+378
-362
lines changed

15 files changed

+378
-362
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Logs
22

3+
## v0.0.3
4+
5+
- extend cookie api to accept an object for cookie options
6+
- upgrade modules to fix vulnerabilities
7+
8+
39
## v0.0.2
410

511
- speed up building by replacing `npx` with `./node_modules/.bin/`

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
utility functions for commonly used http related functions, including:
44

5-
- cookie(key,value,expire) - getter / setter of cookie.
5+
- cookie(key,value,opt) - getter / setter of cookie.
66
- if `value` is omitted, return the cookie corresponding to `key`.
77
- return undefined if `key` is not found in cookie.
8+
- opt: either a string for expiration date, or an object with cookie options such as:
9+
- `expires`
10+
- `max-afge`
11+
- `path`
812
- qs(key) - get value for `key` in querystring
913
- return key-value pair hash if key is omitted.
1014
- return composed query string if `key` is a hash for key-value pairs.

dist/cookie.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
(function(){
2-
module.exports = function(k, v, expire){
3-
var hash;
2+
module.exports = function(k, v, o){
3+
var r, _k, yet$, _v, hash;
44
if (v) {
5-
return document.cookie = (k + "=" + v) + (expire ? ";expires=" + expire : "");
5+
r = "";
6+
if (typeof o === 'object') {
7+
for (_k in yet$ = true, o) {
8+
_v = o[_k];
9+
yet$ = false;
10+
r += ";" + _k + "=" + _v;
11+
} if (yet$) {
12+
if (typeof o === 'string') {
13+
r = ";expires=" + o;
14+
}
15+
}
16+
}
17+
return document.cookie = (k + "=" + v) + r;
618
}
719
hash = {};
820
(document.cookie || '').split(';').map(function(it){

dist/cookie.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.httputil = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
22
(function(){
3-
module.exports = function(k, v, expire){
4-
var hash;
3+
module.exports = function(k, v, o){
4+
var r, _k, yet$, _v, hash;
55
if (v) {
6-
return document.cookie = (k + "=" + v) + (expire ? ";expires=" + expire : "");
6+
r = "";
7+
if (typeof o === 'object') {
8+
for (_k in yet$ = true, o) {
9+
_v = o[_k];
10+
yet$ = false;
11+
r += ";" + _k + "=" + _v;
12+
} if (yet$) {
13+
if (typeof o === 'string') {
14+
r = ";expires=" + o;
15+
}
16+
}
17+
}
18+
return document.cookie = (k + "=" + v) + r;
719
}
820
hash = {};
921
(document.cookie || '').split(';').map(function(it){

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/qs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)