Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
fix: sorting function needs to return an integer
Browse files Browse the repository at this point in the history
The sorting function was returning a boolean, which is wrong.
For proper comparison it needs to return an integer.

Intrestingly enough, this issue only surfaced in the Browser
test run on Windows. There somehow the sorting function of a
two element array gets the second element first, then the
second element.
  • Loading branch information
vmx committed Nov 7, 2018
1 parent 3ea093e commit 662d8ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/createResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function createResolver (multicodec, EthObjClass, mapFromEthObject) {
// only match whole path chunks
matches = matches.filter((child) => child.path.split('/').every((part, index) => part === pathParts[index]))
// take longest match
const sortedMatches = matches.sort((a, b) => a.path.length < b.path.length)
const sortedMatches = matches.sort((a, b) => b.path.length - a.path.length)
const treeResult = sortedMatches[0]

if (!treeResult) {
Expand Down

0 comments on commit 662d8ec

Please sign in to comment.