From 0bdbca30d4612331d241479e310e5e3489b8b392 Mon Sep 17 00:00:00 2001 From: MICHAEL JACKSON Date: Wed, 13 Sep 2017 10:02:36 -0700 Subject: [PATCH] Provide assets on all search hits --- server/npm/search.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/server/npm/search.js b/server/npm/search.js index d1e2115..940c259 100644 --- a/server/npm/search.js +++ b/server/npm/search.js @@ -14,16 +14,17 @@ function enhanceHit(hit) { resolve(hit) } else { + // We don't have any global paths for this package yet. Try + // using the "bare" URL. + hit.assets = [ + `https://unpkg.com/${hit.name}@${hit.version}` + ] + resolve(hit) } }) } -function byRelevanceDescending(a, b) { - // Hits that have assets are more relevant. - return a.assets ? (b.assets ? 0 : -1) : (b.assets ? 1 : 0) -} - // add concatenated name for more relevance for people spelling without spaces // think: createreactnative instead of create-react-native-app function concat(string) { @@ -65,8 +66,6 @@ function search(query, page) { Promise.all( value.hits.map(enhanceHit) ).then(function (hits) { - hits.sort(byRelevanceDescending) - const totalHits = value.nbHits const totalPages = value.nbPages