Skip to content

Commit

Permalink
Bump version number and rebuild for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Virgen committed Dec 23, 2014
1 parent d0aecd7 commit 6cbffba
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api-angular-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 44 additions & 8 deletions api-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,7 @@

//TODO: support arrays as values
if (null !== call.params[key] && call.params.hasOwnProperty(key)) {
params.push(
// Keys and values must be encoded to
// prevent accidental breakage of string
// splits by `=` and `&`.
encodeURIComponent(key) +
"=" +
encodeURIComponent(call.params[key])
);
params.push(parameterize(key, call.params[key]));
}
}

Expand All @@ -227,6 +220,49 @@
return params.join('&');
};

var parameterize = function(key, value) {
var type = typeof value;
switch (type) {
case 'string':
case 'number':
case 'boolean':
return parameterizePrimitive(key, value);
break;

case 'object':
// `null` is considered an "object"
return (null === value) ? parameterizePrimitive(key, value) : parameterizeObject(key, value);
break;

default:
throw new Error("Unable to parameterize key " + key + " with type " + type);
}
};

var parameterizePrimitive = function(key, value) {
// Keys and values must be encoded to
// prevent accidental breakage of string
// splits by `=` and `&`.
return encodeURIComponent(key) + "=" + encodeURIComponent(value);
};

var parameterizeObject = function(key, value) {
var params = [];
if (Array.isArray(value)) {
for (var i = 0, len = value.length; i < len; i++) {
params.push(encodeURIComponent(key) + "[]=" + encodeURIComponent(value[i]));
}
} else {
// assume object
for (var subkey in value) {
if (!value.hasOwnProperty(subkey)) continue;
params.push(encodeURIComponent(key) + "[" + encodeURIComponent(subkey) + "]=" + encodeURIComponent(value[subkey]));
}
}

return params.join('&');
};

// Recursively merge properties of two objects
// Adapted from http://stackoverflow.com/a/383245/249394
function mergeRecursive(obj1, obj2) {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tagged-api-client",
"version": "0.0.12",
"version": "0.1.1",
"authors": [
"Hector Virgen <hvirgen@tagged.com>"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tagged-api",
"version": "0.1.0",
"version": "0.1.1",
"description": "API client for Tagged with support for nodejs and angularjs",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 6cbffba

Please sign in to comment.