@zulip/shared
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -37,3 +37,8 @@ /* | ||
function query_matches_string(query, source_str, split_char) { | ||
// This function attempts to match a query with a source text. | ||
// * query is the user-entered search query | ||
// * source_str is the string we're matching in, e.g. a user's name | ||
// * split_char is the separator for this syntax (e.g. ' '). | ||
export function query_matches_string(query, source_str, split_char) { | ||
source_str = source_str.toLowerCase(); | ||
source_str = remove_diacritics(source_str); | ||
@@ -54,16 +59,2 @@ | ||
// This function attempts to match a query with source's attributes. | ||
// * query is the user-entered search query | ||
// * Source is the object we're matching from, e.g. a user object | ||
// * match_attrs are the values associated with the target object that | ||
// the entered string might be trying to match, e.g. for a user | ||
// account, there might be 2 attrs: their full name and their email. | ||
// * split_char is the separator for this syntax (e.g. ' '). | ||
export function query_matches_source_attrs(query, source, match_attrs, split_char) { | ||
return match_attrs.some((attr) => { | ||
const source_str = source[attr].toLowerCase(); | ||
return query_matches_string(query, source_str, split_char); | ||
}); | ||
} | ||
function clean_query(query) { | ||
@@ -86,2 +77,11 @@ query = remove_diacritics(query); | ||
export const is_unicode_emoji = (emoji) => | ||
emoji.reaction_type === "unicode_emoji" && emoji.emoji_code; | ||
export const parse_unicode_emoji_code = (code) => | ||
code | ||
.split("-") | ||
.map((hex) => String.fromCodePoint(Number.parseInt(hex, 16))) | ||
.join(""); | ||
export function get_emoji_matcher(query) { | ||
@@ -93,3 +93,5 @@ // replace spaces with underscores for emoji matching | ||
return function (emoji) { | ||
return query_matches_source_attrs(query, emoji, ["emoji_name"], "_"); | ||
const matches_emoji_literal = | ||
is_unicode_emoji(emoji) && parse_unicode_emoji_code(emoji.emoji_code) === query; | ||
return matches_emoji_literal || query_matches_string(query, emoji.emoji_name, "_"); | ||
}; | ||
@@ -96,0 +98,0 @@ } |
{ | ||
"name": "@zulip/shared", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"license": "Apache-2.0", | ||
@@ -10,5 +10,5 @@ "scripts": { | ||
"dependencies": { | ||
"katex": "^0.15.3", | ||
"katex": "^0.16.2", | ||
"lodash": "^4.17.19" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44967
23
732
1
+ Addedkatex@0.16.11(transitive)
- Removedkatex@0.15.6(transitive)
Updatedkatex@^0.16.2