MCPcopy Index your code
hub / github.com/restify/node-restify / parseHeader

Function parseHeader

lib/plugins/oauth2TokenParser.js:21–39  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

19
20*/
21function parseHeader(req) {
22 if (req.headers && req.headers.authorization) {
23 var credentialsIndex = 1;
24 var parts = req.headers.authorization.split(' ');
25 var partsExpectedLength = 2;
26 var schemeIndex = 0;
27
28 if (parts.length === partsExpectedLength) {
29 var credentials = parts[credentialsIndex];
30 var scheme = parts[schemeIndex];
31
32 if (/^Bearer$/i.test(scheme)) {
33 return credentials;
34 }
35 }
36 }
37
38 return null;
39}
40
41/**
42 * Returns a plugin that will parse the client's request for an OAUTH2

Callers 1

parseOauth2TokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected