blob: 12f616eeac03f9beef365116a8ba8ea5b5c466e2 (
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(content []byte) []byte {
return ar.replaceInHTML(content)
})
return
}
func AbsURLInXML(absURL string) (trs []link, err error) {
initAbsurlReplacer(absURL)
trs = append(trs, func(content []byte) []byte {
return ar.replaceInXML(content)
})
return
}
|