Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Fix bugs on windows path separator
Browse files Browse the repository at this point in the history
  • Loading branch information
andylokandy committed Apr 16, 2019
1 parent a2c709e commit 4ea6aaf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/remote/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use semver::Version;
use semver_constraints::Constraint;
use serde_derive::{Deserialize, Serialize};
use serde_json;
use simsearch::SimSearch;
use simsearch::{SearchOptions, SimSearch};
use std::{
fs,
io::{self, prelude::*, BufReader},
Expand Down Expand Up @@ -183,7 +183,8 @@ impl Indices {
}

pub fn search(&self, query: &str) -> Res<Vec<(Name, Version, &IndexRes)>> {
let mut engine: SimSearch<(&IndexRes, &str)> = SimSearch::new();
let mut engine: SimSearch<(&IndexRes, &str)> =
SimSearch::new_with(SearchOptions::new().stop_words(&["/", "\\"]));
let x = self
.indices
.iter()
Expand All @@ -195,7 +196,7 @@ impl Indices {
engine.insert((ir, pkg), pkg);
}
let pkgs = engine.search(query);

pkgs.iter().map(|(ir, pkg)| {
let name = Name::from_str(pkg).unwrap();
let ix = &self.indices[*ir];
Expand Down Expand Up @@ -322,7 +323,7 @@ impl Index {
.filter_map(|x| x.ok())
.map(move |x| {
let stripped = x.path().strip_prefix(&root_path).unwrap();
stripped.to_string_lossy().to_string()
stripped.to_string_lossy().replace("\\", "/").to_string()
})
}

Expand Down

0 comments on commit 4ea6aaf

Please sign in to comment.