consolidate defs
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
export const TAG_REGEX = /(?:^|\s)(#[^\d\s]\S*)(?=\s)?/gi
|
export const TAG_REGEX = /(?:^|\s)(#[^\d\s]\S*)(?=\s)?/gi
|
||||||
export const ENDING_PUNCTUATION_REGEX = /\p{P}+$/gu
|
export const ENDING_PUNCTUATION_REGEX = /\p{P}+$/gu
|
||||||
export const LEADING_HASH_REGEX = /^#/
|
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)
|
return 4294967296 * (2097151 & h2) + (h1 >>> 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function uniq(tags: string[]) {
|
||||||
|
return Array.from(new Set(tags))
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,21 +22,8 @@ import * as Sheet from 'view/com/sheets/Base'
|
|||||||
import {useStores} from 'state/index'
|
import {useStores} from 'state/index'
|
||||||
import {ActivityIndicator} from 'react-native'
|
import {ActivityIndicator} from 'react-native'
|
||||||
import {TagInputEntryButton} from './TagInputEntryButton'
|
import {TagInputEntryButton} from './TagInputEntryButton'
|
||||||
import {
|
import {sanitize} from 'lib/strings/hashtags'
|
||||||
ENDING_PUNCTUATION_REGEX,
|
import {uniq} from 'lib/strings/helpers'
|
||||||
LEADING_HASH_REGEX,
|
|
||||||
} from 'lib/strings/hashtags'
|
|
||||||
|
|
||||||
function uniq(tags: string[]) {
|
|
||||||
return Array.from(new Set(tags))
|
|
||||||
}
|
|
||||||
|
|
||||||
function sanitize(tagString: string) {
|
|
||||||
return tagString
|
|
||||||
.trim()
|
|
||||||
.replace(LEADING_HASH_REGEX, '')
|
|
||||||
.replace(ENDING_PUNCTUATION_REGEX, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TagInput({
|
export function TagInput({
|
||||||
max = 8,
|
max = 8,
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ import {
|
|||||||
} from '@fortawesome/react-native-fontawesome'
|
} from '@fortawesome/react-native-fontawesome'
|
||||||
import {Pin} from 'pind'
|
import {Pin} from 'pind'
|
||||||
|
|
||||||
import {
|
|
||||||
ENDING_PUNCTUATION_REGEX,
|
|
||||||
LEADING_HASH_REGEX,
|
|
||||||
} from 'lib/strings/hashtags'
|
|
||||||
import {isWeb} from 'platform/detection'
|
import {isWeb} from 'platform/detection'
|
||||||
import {TagsAutocompleteModel} from 'state/models/ui/tags-autocomplete'
|
import {TagsAutocompleteModel} from 'state/models/ui/tags-autocomplete'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
@@ -26,17 +22,8 @@ import {Text} from 'view/com/util/text/Text'
|
|||||||
import {useStores} from 'state/index'
|
import {useStores} from 'state/index'
|
||||||
import {TagInputEntryButton} from './TagInputEntryButton'
|
import {TagInputEntryButton} from './TagInputEntryButton'
|
||||||
import {TextInputFocusEventData} from 'react-native'
|
import {TextInputFocusEventData} from 'react-native'
|
||||||
|
import {sanitize} from 'lib/strings/hashtags'
|
||||||
function uniq(tags: string[]) {
|
import {uniq} from 'lib/strings/helpers'
|
||||||
return Array.from(new Set(tags))
|
|
||||||
}
|
|
||||||
|
|
||||||
function sanitize(tagString: string) {
|
|
||||||
return tagString
|
|
||||||
.trim()
|
|
||||||
.replace(LEADING_HASH_REGEX, '')
|
|
||||||
.replace(ENDING_PUNCTUATION_REGEX, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TagInput({
|
export function TagInput({
|
||||||
max = 8,
|
max = 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user