@trayio/commons
Advanced tools
Comparing version 4.40.0 to 4.41.0
@@ -30,3 +30,9 @@ "use strict"; | ||
const Serialization_1 = require("../serialization/Serialization"); | ||
const getHeader = (headers, name) => O.fromNullable(headers[name.toLowerCase()]); | ||
const getHeader = (headers, name) => { | ||
const lowerCasedHeaders = Object.keys(headers).reduce((acc, key) => ({ | ||
...acc, | ||
[key.toLowerCase()]: headers[key], | ||
}), {}); | ||
return O.fromNullable(lowerCasedHeaders[name.toLowerCase()]); | ||
}; | ||
var HttpMethod; | ||
@@ -33,0 +39,0 @@ (function (HttpMethod) { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const O = __importStar(require("fp-ts/Option")); | ||
const Http_1 = require("./Http"); | ||
@@ -134,2 +158,20 @@ describe('HttpHeaders', () => { | ||
}); | ||
it('should extract bearer token from headers', () => { | ||
const headers = { | ||
'content-type': 'application/json', | ||
'content-length': '100', | ||
authorization: 'bearer 1234', | ||
}; | ||
const result = Http_1.HttpHeaders.extractBearerToken(headers); | ||
expect(result).toEqual(O.some('1234')); | ||
}); | ||
it('should extract bearer token from headers when headers are capitalized', () => { | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
'Content-Length': '100', | ||
Authorization: 'Bearer 1234', | ||
}; | ||
const result = Http_1.HttpHeaders.extractBearerToken(headers); | ||
expect(result).toEqual(O.some('1234')); | ||
}); | ||
}); |
{ | ||
"name": "@trayio/commons", | ||
"version": "4.40.0", | ||
"version": "4.41.0", | ||
"description": "Extensions to the standard/core libraries and basic features", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196512
4052