mirror of
https://github.com/supabase/supabase.git
synced 2026-07-02 12:44:35 +08:00
18 lines
475 B
TypeScript
18 lines
475 B
TypeScript
export const getAnchor = (text: any): string | undefined => {
|
|
if (typeof text !== 'string') {
|
|
return undefined
|
|
} else {
|
|
const [anchor] = text.match(/{#[a-z-]*}/g) || []
|
|
return anchor !== undefined ? anchor.slice(2, anchor.length - 1) : undefined
|
|
}
|
|
}
|
|
|
|
export const removeAnchor = (text: any) => {
|
|
if (typeof text !== 'string') {
|
|
return text
|
|
} else {
|
|
if (text.indexOf('{#') > 0) return text.slice(0, text.indexOf('{#'))
|
|
else return text
|
|
}
|
|
}
|