Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Normalize case in event headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vvondra committed Aug 5, 2018
1 parent 4b250e6 commit 360092e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const handler = async (event, context, callback) => {

const body = utils.normalizeBody(querystring.parse(event.body));

let eventHeaders;
let device;
let deviceType;
let user;
Expand Down Expand Up @@ -96,13 +97,12 @@ export const handler = async (event, context, callback) => {

// Browser extension sends body, web and mobile send header.
// iOS sends lower case header with string value.
deviceType = parseInt(event.headers['Device-Type'], 10);
if (Number.isNaN(deviceType)) {
eventHeaders = utils.normalizeBody(event.headers);
deviceType = body.devicetype;
if (!Number.isNaN(eventHeaders['device-type'])) {
deviceType = parseInt(event.headers['device-type'], 10);
}
if (Number.isNaN(deviceType)) {
deviceType = body.devicetype;
}

if (body.devicename && deviceType) {
device.set({
// Browser extension sends body, web and mobile send header
Expand Down

0 comments on commit 360092e

Please sign in to comment.