Last active
June 11, 2016 08:45
-
-
Save windwp/f8c3a91fbde7930bdd4e2f655ddaad81 to your computer and use it in GitHub Desktop.
javascript snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
capitalize(value) { | |
return value.toLowerCase().replace( /\b\w/g, function (m) { | |
return m.toUpperCase(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private convertObjToUrlQuery(obj: any): string { | |
if (!obj) return ''; | |
var parts = []; | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
var query = encodeURIComponent(key) + '=' + (((typeof obj[key]) === 'string') ? encodeURIComponent(obj[key]) : encodeURIComponent(JSON.stringify(obj[key]))); | |
parts.push(query); | |
} | |
} | |
return "?" + parts.join('&'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment