diff --git a/extension/main.js b/extension/main.js index a4a5d47..0abbe8b 100644 --- a/extension/main.js +++ b/extension/main.js @@ -197,10 +197,10 @@ omnibox.addPrefixQueryEvent("?", { let description; if (query.startsWith("??")) { content = `https://github.com/rust-lang/rfcs/pull/${feat.rfc}`; - description = `RFC: ${c.match(feat.match)} - ${feat.rest}` + description = `RFC: ${c.match(c.escape(feat.match))} - ${c.escape(feat.rest)}` } else { content = `https://caniuse.rs/features/${feat.slug}`; - description = `Can I use: ${c.match(feat.match)} - ${feat.rest}` + description = `Can I use: ${c.match(c.escape(feat.match))} - ${c.escape(feat.rest)}` } return { content, diff --git a/extension/search/caniuse.js b/extension/search/caniuse.js index 6c64641..e734d0f 100644 --- a/extension/search/caniuse.js +++ b/extension/search/caniuse.js @@ -1,6 +1,6 @@ // `caniuseIndex` is an array of `feat`: [feat] // where each `feat` is an ordered array of: -// - Rust version that the feature is stablized +// - Rust version that the feature is stabilized // - The slug used in caniuse.rs URL // - (null-able) The flag needed to use the feature in (unstable) Rust // - A title that describes the feature @@ -10,24 +10,24 @@ function CaniuseSearch(index) { this.feats = {}; index.forEach(([ver, slug, flag, title, rfc]) => { // `match` is for highlighting - let match = flag ?? title; + let match = flag || title; // `rest` contains other information in description let rest = ((flag == null) ? [ver] : [title, ver]).join(" - "); - let searchTerm = `${match}${rest}`.replace(/[-_\s#\?]/ig, ""); + let searchTerm = `${match}${rest}`.replace(/[-_\s#?]/ig, ""); this.feats[searchTerm] = { slug, match, rest, rfc }; }); this.searchTerms = Object.keys(this.feats); } CaniuseSearch.prototype.search = function (rawKeyword) { - let keyword = rawKeyword.replace(/[-_\s#\?]/ig, ""); + let keyword = rawKeyword.toLowerCase().replace(/[-_\s#?]/ig, ""); let result = []; for (let searchTerm of this.searchTerms) { if (searchTerm.length < keyword.length) continue; - let foundAt = searchTerm.indexOf(keyword); + let foundAt = searchTerm.toLowerCase().indexOf(keyword); if (foundAt > -1) { let rfc = this.feats[searchTerm].rfc; // skip those without RFC when searching for RFCs