@zulip/shared
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -11,3 +11,3 @@ /** The canonical form of the resolved-topic prefix. */ | ||
// It's designed to remove a weird "✔ ✔✔ " prefix, if present. | ||
// Compare maybe_send_resolve_topic_notifications in zerver/lib/actions.py. | ||
// Compare maybe_send_resolve_topic_notifications in zerver/actions/message_edit.py. | ||
const RESOLVED_TOPIC_PREFIX_RE = /^✔ [ ✔]*/; | ||
@@ -14,0 +14,0 @@ |
@@ -40,30 +40,13 @@ /* | ||
// If query doesn't contain a separator, we just want an exact | ||
// match where query is a substring of one of the target characters. | ||
if (query.indexOf(split_char) > 0) { | ||
// If there's a whitespace character in the query, then we | ||
// require a perfect prefix match (e.g. for 'ab cd ef', | ||
// query needs to be e.g. 'ab c', not 'cd ef' or 'b cd | ||
// ef', etc.). | ||
const queries = query.split(split_char); | ||
const sources = source_str.split(split_char); | ||
let i; | ||
for (i = 0; i < queries.length - 1; i += 1) { | ||
if (sources[i] !== queries[i]) { | ||
return false; | ||
} | ||
} | ||
// This block is effectively a final iteration of the last | ||
// loop. What differs is that for the last word, a | ||
// partial match at the beginning of the word is OK. | ||
if (sources[i] === undefined) { | ||
return false; | ||
} | ||
return sources[i].startsWith(queries[i]); | ||
if (!query.includes(split_char)) { | ||
// If query is a single token (doesn't contain a separator), | ||
// the match can be anywhere in the string. | ||
return source_str.includes(query); | ||
} | ||
// For a single token, the match can be anywhere in the string. | ||
return source_str.includes(query); | ||
// If there is a separator character in the query, then we | ||
// require the match to start at the start of a token. | ||
// (E.g. for 'ab cd ef', query could be 'ab c' or 'cd ef', | ||
// but not 'b cd ef'.) | ||
return source_str.startsWith(query) || source_str.includes(split_char + query); | ||
} | ||
@@ -102,17 +85,4 @@ | ||
export const parse_unicode_emoji_code = (code) => { | ||
try { | ||
return code | ||
.split("-") | ||
.map((hex) => String.fromCodePoint(Number.parseInt(hex, 16))) | ||
.join(""); | ||
} catch { | ||
// Code could not be parsed, but instead of throwing an exception | ||
// we return undefined instead of a string. | ||
return undefined; | ||
} | ||
}; | ||
export function get_emoji_matcher(query) { | ||
// replaces spaces with underscores for emoji matching | ||
// replace spaces with underscores for emoji matching | ||
query = query.replace(/ /g, "_"); | ||
@@ -122,7 +92,3 @@ query = clean_query_lowercase(query); | ||
return function (emoji) { | ||
const matches_emoji_literal = | ||
emoji.emoji_code && parse_unicode_emoji_code(emoji.emoji_code) === query; | ||
return ( | ||
matches_emoji_literal || query_matches_source_attrs(query, emoji, ["emoji_name"], "_") | ||
); | ||
return query_matches_source_attrs(query, emoji, ["emoji_name"], "_"); | ||
}; | ||
@@ -171,7 +137,9 @@ } | ||
export function sort_emojis(objs, query) { | ||
const lowerQuery = query.toLowerCase(); | ||
// replace spaces with underscores for emoji matching | ||
query = query.replace(/ /g, "_"); | ||
query = query.toLowerCase(); | ||
function decent_match(name) { | ||
const pieces = name.toLowerCase().split("_"); | ||
return pieces.some((piece) => piece.startsWith(lowerQuery)); | ||
return pieces.some((piece) => piece.startsWith(query)); | ||
} | ||
@@ -178,0 +146,0 @@ |
{ | ||
"name": "@zulip/shared", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"version": "tools/npm-version", | ||
"postversion": "tools/npm-postversion" | ||
}, | ||
"dependencies": { | ||
@@ -6,0 +10,0 @@ "katex": "^0.15.3", |
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
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
20
0
38148
731