From 36bf87361a0ee801f1a23cb5a7c019288fdcfa90 Mon Sep 17 00:00:00 2001 From: rajendrant Date: Wed, 19 Dec 2018 13:43:21 -0800 Subject: [PATCH] Fix path separator for windows --- fuzzaldrin.coffee | 3 ++- package-lock.json | 14 +++++++++++--- package.json | 3 ++- spec/test.coffee | 8 ++++++-- src/common.h | 4 ++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/fuzzaldrin.coffee b/fuzzaldrin.coffee index cedf2406..8d2367bb 100644 --- a/fuzzaldrin.coffee +++ b/fuzzaldrin.coffee @@ -37,6 +37,7 @@ module.exports = obj.filter(query, options) score: (candidate, query, options = {}) -> - binding.score candidate, query, options + options = parseOptions(options) + binding.score candidate, query, options.usePathScoring, options.useExtensionBonus prepareQuery: -> diff --git a/package-lock.json b/package-lock.json index 91ee8834..14aaf2b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -152,9 +152,9 @@ } }, "growl": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.7.0.tgz", - "integrity": "sha1-3i1mE20ALhErpw8/EMMc98NQsto=", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, "inflight": { @@ -186,6 +186,14 @@ "dev": true, "requires": { "growl": "~1.7.0" + }, + "dependencies": { + "growl": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.7.0.tgz", + "integrity": "sha1-3i1mE20ALhErpw8/EMMc98NQsto=", + "dev": true + } } }, "jasmine-node": { diff --git a/package.json b/package.json index 4c3e5a30..98548fde 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "devDependencies": { "fuzzaldrin-plus": "^0.6.0", "jasmine-node": "^1.16.2", - "prebuildify": "^2.6.0" + "prebuildify": "^2.6.0", + "growl": ">=1.10.0" }, "repository": { "type": "git", diff --git a/spec/test.coffee b/spec/test.coffee index f49682f7..4de4ca68 100644 --- a/spec/test.coffee +++ b/spec/test.coffee @@ -16,6 +16,10 @@ testPathScorer = -> [path.join('app', 'components', 'admin', 'member', 'modals', 'edit-payment.html'), 'member edit htm'], [path.join('matchOptimisticB.htaccess'), 'mob.h', useExtensionBonus: true], [path.join('matchOptimisticB_main.html'), 'mob.h', useExtensionBonus: true], + ['0\\Diagnostic', 'diag'], + ['0\\Diagnostic', 'diag0'], + ['0\\0\\0\\diagnostics00', 'diag'], + ['0\\0\\0\\diagnostics00', 'diag0'], ] for test in tests test[2] ?= {} @@ -97,6 +101,6 @@ testBenchmark = -> fuzzaldrinExpected.filter filenames, 'da', maxResults: 10 console.timeEnd('legacy') -# testPathScorer() +testPathScorer() # testFilter() -testBenchmark() +# testBenchmark() diff --git a/src/common.h b/src/common.h index 9058f642..aa718f6d 100644 --- a/src/common.h +++ b/src/common.h @@ -32,7 +32,11 @@ struct Options { bool allowErrors = false; bool usePathScoring = true; bool useExtensionBonus = false; +#ifdef _WIN32 + char pathSeparator = '\\'; +#else char pathSeparator = '/'; +#endif const PreparedQuery preparedQuery; Options(const string &query, size_t maxResults, bool usePathScoring, bool useExtensionBonus) : max_results(maxResults), usePathScoring(usePathScoring), useExtensionBonus(useExtensionBonus), preparedQuery(query, pathSeparator) {}