12 lines
416 B
TypeScript
12 lines
416 B
TypeScript
import { diff_match_patch } from 'diff-match-patch'
|
|
import { homePageURL } from '../env'
|
|
|
|
export const getHighlightLocation = (patch: string): number | undefined => {
|
|
const dmp = new diff_match_patch()
|
|
const patches = dmp.patch_fromText(patch)
|
|
return patches[0].start1 || undefined
|
|
}
|
|
|
|
export const getHighlightUrl = (slug: string, highlightId: string): string =>
|
|
`${homePageURL()}/me/${slug}#${highlightId}`
|