Parse tags to get unique ignoring case
This commit is contained in:
		
							parent
							
								
									bad7a2b543
								
							
						
					
					
						commit
						3ba96028f4
					
				| 
						 | 
					@ -1,8 +1,9 @@
 | 
				
			||||||
 | 
					import _ from 'lodash'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function parseTags(text: string) {
 | 
					export function parseTags(text: string) {
 | 
				
			||||||
  const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
 | 
					  const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
 | 
				
			||||||
  const matches = text.match(regex) || []
 | 
					  const matches = (text.match(regex) || []).map((match) =>
 | 
				
			||||||
  return matches.map((match) => {
 | 
					    match.trim().substring(1)
 | 
				
			||||||
    const tag = match.trim().substring(1)
 | 
					  )
 | 
				
			||||||
    return tag
 | 
					  return _.uniqBy(matches, (tag) => tag.toLowerCase())
 | 
				
			||||||
  })
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user