Skip to content

Instantly share code, notes, and snippets.

View dzuluaga's full-sized avatar

Diego Zuluaga dzuluaga

View GitHub Profile
@dzuluaga
dzuluaga / parseAuthorizationHeader.js
Last active August 29, 2015 14:12
JavaScript Regular Expression to Parse OAuth 1.0a Authorization Headers
/**
* This function parses a string in a form of an authorization header and returns a string with two elements, the matching string and the
* value. The string has been escaped with http://www.freeformatter.com/javascript-escape.html#ad-output.
*
* @strHeader {string} string in a form of an authorization header
* @patternToMatch {rexexp} regular expression to match specific pattern
* @return {array} Returns an array with two elements: ["oauth_token="mHcOQ4lksgr1UUCcVzNYxNMSbr9Y"", "mHcOQ4lksgr1UUCcVzNYxNMSbr9Y"]
*/
function parseAuthorizationHeader(strHeader, patternToMatch){
apiproxy
├── policies
│   └── xmltojson-1.xml
├── proxies
│   └── default.xml
├── targets
│   └── default.xml
└── weather.xml