|
@@ -3,18 +3,17 @@ const purest = require('purest')({ request })
|
|
|
const logger = require('../../logger')
|
|
|
const adapter = require('./adapter')
|
|
|
|
|
|
-
|
|
|
// From https://www.dropbox.com/developers/reference/json-encoding:
|
|
|
//
|
|
|
// This function is simple and has OK performance compared to more
|
|
|
// complicated ones: http://jsperf.com/json-escape-unicode/4
|
|
|
-const charsToEncode = /[\u007f-\uffff]/g;
|
|
|
-function http_header_safe_json(v) {
|
|
|
+const charsToEncode = /[\u007f-\uffff]/g
|
|
|
+function httpHeaderSafeJson (v) {
|
|
|
return JSON.stringify(v).replace(charsToEncode,
|
|
|
- function(c) {
|
|
|
- return '\\u'+('000'+c.charCodeAt(0).toString(16)).slice(-4);
|
|
|
+ function (c) {
|
|
|
+ return '\\u' + ('000' + c.charCodeAt(0).toString(16)).slice(-4)
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
class DropBox {
|
|
@@ -97,7 +96,7 @@ class DropBox {
|
|
|
.options({
|
|
|
version: '2',
|
|
|
headers: {
|
|
|
- 'Dropbox-API-Arg': http_header_safe_json({path: `${id}`})
|
|
|
+ 'Dropbox-API-Arg': httpHeaderSafeJson({path: `${id}`})
|
|
|
}
|
|
|
})
|
|
|
.auth(token)
|
|
@@ -115,7 +114,7 @@ class DropBox {
|
|
|
.options({
|
|
|
version: '2',
|
|
|
headers: {
|
|
|
- 'Dropbox-API-Arg': http_header_safe_json({path: `${id}`})
|
|
|
+ 'Dropbox-API-Arg': httpHeaderSafeJson({path: `${id}`})
|
|
|
}
|
|
|
})
|
|
|
.auth(token)
|