Skip to content

Commit

Permalink
Removing unneeded regex keys, removing truthy statements
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jul 29, 2017
1 parent f32323c commit 9f76f57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
7 changes: 0 additions & 7 deletions lib/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const path = require("path"),
compress: /(javascript|json|text|xml|yaml)/,
collection: /(.*)(\/.*)$/,
def: /deflate/,
del: /^DELETE$/,
dir: /\/$/,
end_slash: /\/$/,
ext: /\.[\w+]{1,}$/, // 1 is for source code files, etc.
encode_form: /application\/x-www-form-urlencoded/,
encode_json: /application\/json/,
head: /^HEAD$/,
Expand All @@ -31,11 +28,7 @@ const path = require("path"),
options: /^OPTIONS$/,
order_by: /^order_by\=/,
partial: /^bytes=/,
post: /^POST$/,
put: /^PUT$/,
private: /private/,
root: /^\//,
space: /\s+/,
scheme: /^(\w+\:\/\/)|\//,
trailing: /_.*$/,
trailing_s: /s$/,
Expand Down
12 changes: 6 additions & 6 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ function auth (obj, config) {

function bootstrap (obj, config) {
// Setting headers
if (!config.headers) {
if (config.headers === void 0) {
config.headers = {};
}

Expand Down Expand Up @@ -576,13 +576,13 @@ function bootstrap (obj, config) {
auth(obj, config);

// Starting WebSocket server
if (config.websocket.enabled && uws) {
if (config.websocket.enabled && uws !== void 0) {
obj.websocket = new uws.Server(config.websocket.options);
obj.log("Started WebSocket server on port " + config.websocket.options.port, "debug");
}

// Starting COAP server
if (config.coap.enabled && coap) {
if (config.coap.enabled && coap !== void 0) {
obj.coap = coap.createServer({type: config.coap.options.type});
obj.coap.listen(config.coap.options.port, config.hostname);
obj.log("Started COAP (" + config.coap.options.type + ") server on " + config.hostname + ":" + config.coap.options.port, "debug");
Expand Down Expand Up @@ -627,7 +627,7 @@ function bootstrap (obj, config) {
});

// Disabling compression over SSL due to BREACH
if (config.ssl.cert && config.ssl.key) {
if (config.ssl.cert !== null && config.ssl.key !== null) {
config.compress = false;
obj.log("Compression over SSL is disabled for your protection", "debug");
}
Expand Down Expand Up @@ -734,10 +734,10 @@ function hypermedia (server, req, rep, headers) {
if (i instanceof Object) {
marshal(i, "item", req.parsed.pathname.replace(regex.trailing_slash, "").replace(regex.leading, ""));
} else {
let li = i.toString();
const li = i.toString();

if (li !== collection) {
let uri = li.indexOf("//") > -1 || li.indexOf("/") === 0 ? li : (collection + "/" + li).replace(/^\/\//, "/");
const uri = li.indexOf("//") > -1 || li.indexOf("/") === 0 ? li : (collection + "/" + li).replace(/^\/\//, "/");

if (server.allowed("GET", uri, req.host)) {
rep.links.push({uri: uri, rel: "item"});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an elastic REST API gateway for node.js",
"version": "5.0.1",
"version": "5.0.2",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit 9f76f57

Please sign in to comment.