Skip to content

Commit a040aaf

Browse files
committed
Adds parser for SDK version
1 parent 7a2e906 commit a040aaf

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/middlewares.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ var Parse = require('parse/node').Parse;
66
var auth = require('./Auth');
77
var Config = require('./Config');
88

9+
function clientSDKFromVersion(version) {
10+
let versionRE = /([-a-zA-Z]+)([0-9\.]+)/;
11+
let match = version.toLowerCase().match(versionRE);
12+
if (match && match.length === 3) {
13+
return {
14+
sdk: match[1],
15+
version: match[2]
16+
}
17+
}
18+
}
19+
920
// Checks that the request is authorized for this app and checks user
1021
// auth too.
1122
// The bodyparser should run before this middleware.
@@ -25,7 +36,8 @@ function handleParseHeaders(req, res, next) {
2536
clientKey: req.get('X-Parse-Client-Key'),
2637
javascriptKey: req.get('X-Parse-Javascript-Key'),
2738
dotNetKey: req.get('X-Parse-Windows-Key'),
28-
restAPIKey: req.get('X-Parse-REST-API-Key')
39+
restAPIKey: req.get('X-Parse-REST-API-Key'),
40+
clientVersion: req.get('X-Parse-Client-Version')
2941
};
3042

3143
var basicAuth = httpAuth(req);
@@ -93,6 +105,10 @@ function handleParseHeaders(req, res, next) {
93105
}
94106
}
95107

108+
if (info.clientVersion) {
109+
info.clientSDK = clientSDKFromVersion(info.clientVersion);
110+
}
111+
96112
if (fileViaJSON) {
97113
// We need to repopulate req.body with a buffer
98114
var base64 = req.body.base64;

0 commit comments

Comments
 (0)