consolidate defs
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
export const TAG_REGEX = /(?:^|\s)(#[^\d\s]\S*)(?=\s)?/gi
|
||||
export const ENDING_PUNCTUATION_REGEX = /\p{P}+$/gu
|
||||
export const LEADING_HASH_REGEX = /^#/
|
||||
|
||||
export function sanitize(tagString: string) {
|
||||
return tagString
|
||||
.trim()
|
||||
.replace(LEADING_HASH_REGEX, '')
|
||||
.replace(ENDING_PUNCTUATION_REGEX, '')
|
||||
}
|
||||
|
||||
@@ -32,3 +32,7 @@ export function toHashCode(str: string, seed = 0): number {
|
||||
|
||||
return 4294967296 * (2097151 & h2) + (h1 >>> 0)
|
||||
}
|
||||
|
||||
export function uniq(tags: string[]) {
|
||||
return Array.from(new Set(tags))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user