Utils
propertyBaas.Utils
A class to model a Baas Utils.
Baas.Utils = (function () {
A class to model a Baas Utils.
Baas.Utils = (function () {
Tests if the string is a uuid
function isUUID(uuid){
var uuidValueRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
if (!uuid) return false;
return uuidValueRegex.test(uuid);
}
method to encode the query string parameters
@method encodeParams
@public
@params {object} params - an object of name value pairs that will be urlencoded
@return {string} Returns the encoded string
function encodeParams(params){
tail = [];
var item = [];
if (params instanceof Array) {
for (i in params) {
item = params[i];
if ((item instanceof Array) && (item.length > 1)) {
tail.push(item[0] + "=" + encodeURIComponent(item[1]));
}
}
} else {
for (var key in params) {
if (params.hasOwnProperty(key)) {
var value = params[key];
if (value instanceof Array) {
for (i in value) {
item = value[i];
tail.push(key + "=" + encodeURIComponent(item));
}
} else {
tail.push(key + "=" + encodeURIComponent(value));
}
}
}
}
return tail.join("&");
}
return{
isUUID:isUUID,
encodeParams:encodeParams
}
})()