Apply no-buffer-constructor lint rule
This commit is contained in:
1 parent
d85afcd2b5
commit
b43088c03c
6 files changed
+8
-7
No files matched your search
+2
-1
@@ -13,6 +13,7 @@
|
|||||||
"handle-callback-err": "error",
|
"handle-callback-err": "error",
|
||||||
"prefer-arrow-callback": "error",
|
"prefer-arrow-callback": "error",
|
||||||
"curly": ["error", "multi-or-nest", "consistent"],
|
"curly": ["error", "multi-or-nest", "consistent"],
|
||||||
"consistent-return": ["error", {"treatUndefinedAsUnspecified": true}]
|
"consistent-return": ["error", {"treatUndefinedAsUnspecified": true}],
|
||||||
|
"no-buffer-constructor": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -54,7 +54,7 @@ function parseAuthHeader(authHeader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function basic(username, password) {
|
function basic(username, password) {
|
||||||
return "Basic " + new Buffer(`${username}:${password}`).toString("base64");
|
return "Basic " + Buffer.from(`${username}:${password}`).toString("base64");
|
||||||
}
|
}
|
||||||
|
|
||||||
function digest(username, password, uri, httpMethod, body, authHeader) {
|
function digest(username, password, uri, httpMethod, body, authHeader) {
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ function generateDeviceId(deviceIdStruct) {
|
|||||||
// Escapes everything except alphanumerics and underscore
|
// Escapes everything except alphanumerics and underscore
|
||||||
function esc(str) {
|
function esc(str) {
|
||||||
return str.replace(/[^A-Za-z0-9_]/g, chr => {
|
return str.replace(/[^A-Za-z0-9_]/g, chr => {
|
||||||
const buf = new Buffer(chr, "utf8");
|
const buf = Buffer.from(chr, "utf8");
|
||||||
let rep = "";
|
let rep = "";
|
||||||
for (let b of buf) rep += "%" + b.toString(16).toUpperCase();
|
for (let b of buf) rep += "%" + b.toString(16).toUpperCase();
|
||||||
return rep;
|
return rep;
|
||||||
|
|||||||
+1
-1
@@ -1058,7 +1058,7 @@ function listener(httpRequest, httpResponse) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
stream.on("end", () => {
|
stream.on("end", () => {
|
||||||
const body = new Buffer(bytes);
|
const body = Buffer.allocUnsafe(bytes);
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
chunk.copy(body, offset, 0, chunk.length);
|
chunk.copy(body, offset, 0, chunk.length);
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ function listener(request, response) {
|
|||||||
|
|
||||||
function getBody() {
|
function getBody() {
|
||||||
// Write all chunks into a Buffer
|
// Write all chunks into a Buffer
|
||||||
const body = new Buffer(bytes);
|
const body = Buffer.allocUnsafe(bytes);
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
chunk.copy(body, offset, 0, chunk.length);
|
chunk.copy(body, offset, 0, chunk.length);
|
||||||
|
|||||||
+2
-2
@@ -524,7 +524,7 @@ function response(rpc) {
|
|||||||
SOAPServer: SERVER_NAME
|
SOAPServer: SERVER_NAME
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!rpc) return { code: 204, headers: headers, data: new Buffer(0) };
|
if (!rpc) return { code: 204, headers: headers, data: Buffer.allocUnsafe(0) };
|
||||||
|
|
||||||
const env = createSoapEnv(rpc.cwmpVersion);
|
const env = createSoapEnv(rpc.cwmpVersion);
|
||||||
const header = env.node("soap-env:Header");
|
const header = env.node("soap-env:Header");
|
||||||
@@ -589,7 +589,7 @@ function response(rpc) {
|
|||||||
return {
|
return {
|
||||||
code: 200,
|
code: 200,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
data: new Buffer(env.doc().toString(LIBXMLJS_SAVE_OPTIONS))
|
data: env.doc().toString(LIBXMLJS_SAVE_OPTIONS)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user