blob: b4bd1dff4c6c7b6e4ba1777d2ccb6b6f7bfd6278 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package transform
import (
"sync"
)
var absURLInit sync.Once
var ar *absURLReplacer
// for performance reasons, we reuse the first baseURL given
func initAbsURLReplacer(baseURL string) {
absURLInit.Do(func() {
ar = newAbsURLReplacer(baseURL)
})
}
func AbsURL(absURL string) (trs []link, err error) {
initAbsURLReplacer(absURL)
trs = append(trs, func(rw contentRewriter) {
ar.replaceInHTML(rw)
})
return
}
func AbsURLInXML(absURL string) (trs []link, err error) {
initAbsURLReplacer(absURL)
trs = append(trs, func(rw contentRewriter) {
ar.replaceInXML(rw)
})
return
}
|