Created
August 23, 2017 16:42
-
-
Save garenyondem/caf62d0c0845f3a4ba0499ecbec86ed9 to your computer and use it in GitHub Desktop.
Extract Platform From UserAgent
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
var constants = require('./constants'); | |
function extractPlatformFromUserAgent(reqHeaders) { | |
if (!!reqHeaders['user-agent'].match(/iOS/) || !!reqHeaders['user-agent'].match(/iPhone/) || !!reqHeaders['user-agent'].match(/iPad/)) { | |
return constants.platform.ios; | |
} else if (!!reqHeaders['user-agent'].match(/Android/)) { | |
return constants.platform.android; | |
} else { | |
return null; | |
} | |
} | |
module.exports = extractPlatformFromUserAgent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment