| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "regexp" |
| 5 | "strings" |
| 6 | |
| 7 | "reasonix/internal/control" |
| 8 | ) |
| 9 | |
| 10 | func rewriteDraftExternalFileRef(input, path, token string) string { |
| 11 | old := "@" + control.EscapeRefPath(path) |
| 12 | pattern := regexp.MustCompile(regexp.QuoteMeta(old) + `($|\s)`) |
| 13 | return pattern.ReplaceAllStringFunc(input, func(match string) string { |
| 14 | return "@" + control.EscapeRefPath(token) + strings.TrimPrefix(match, old) |
| 15 | }) |
| 16 | } |
| 17 |