Skip to content

Commit

Permalink
Standard
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed Nov 6, 2020
1 parent 0118ab6 commit 771d019
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ Router.prototype._insert = function _insert (method, path, kind, params, handler
// let's split the node and add a new child
if (len < prefixLen) {
node = new Node(
{ prefix: prefix.slice(len),
{
prefix: prefix.slice(len),
children: currentNode.children,
kind: currentNode.kind,
handlers: new Node.Handlers(currentNode.handlers),
regex: currentNode.regex,
versions: currentNode.versions }
versions: currentNode.versions
}
)
if (currentNode.wildcardChild !== null) {
node.wildcardChild = currentNode.wildcardChild
Expand Down Expand Up @@ -585,7 +587,7 @@ Router.prototype.prettyPrint = function () {
}

for (var i in http.METHODS) {
if (!http.METHODS.hasOwnProperty(i)) continue
if (!http.METHODS.hasOwnProperty(i)) continue // eslint-disable-line
const m = http.METHODS[i]
const methodName = m.toLowerCase()

Expand Down
20 changes: 10 additions & 10 deletions test/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ test('Method already declared', t => {
findMyWay.on('GET', '/test', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test\'')
}
})

Expand All @@ -198,14 +198,14 @@ test('Method already declared [ignoreTrailingSlash=true]', t => {
findMyWay.on('GET', '/test', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test\'')
}

try {
findMyWay.on('GET', '/test/', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/\'')
}
})

Expand All @@ -219,14 +219,14 @@ test('Method already declared [ignoreTrailingSlash=true]', t => {
findMyWay.on('GET', '/test', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test\'')
}

try {
findMyWay.on('GET', '/test/', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/\'')
}
})
})
Expand All @@ -243,7 +243,7 @@ test('Method already declared nested route', t => {
findMyWay.on('GET', '/test/hello', () => {})
t.fail('method already delcared in nested route')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/hello'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\'')
}
})

Expand All @@ -262,14 +262,14 @@ test('Method already declared nested route [ignoreTrailingSlash=true]', t => {
findMyWay.on('GET', '/test/hello', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/hello'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\'')
}

try {
findMyWay.on('GET', '/test/hello/', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/hello/'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello/\'')
}
})

Expand All @@ -285,14 +285,14 @@ test('Method already declared nested route [ignoreTrailingSlash=true]', t => {
findMyWay.on('GET', '/test/hello', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/hello'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello\'')
}

try {
findMyWay.on('GET', '/test/hello/', () => {})
t.fail('method already declared')
} catch (e) {
t.is(e.message, `Method 'GET' already declared for route '/test/hello/'`)
t.is(e.message, 'Method \'GET\' already declared for route \'/test/hello/\'')
}
})
})
2 changes: 1 addition & 1 deletion test/version.custom-versioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const customVersioning = {
}
},
deriveVersion: (req, ctx) => {
return req.headers['accept']
return req.headers.accept
}
}

Expand Down

0 comments on commit 771d019

Please sign in to comment.