blob: e64f8394e34e200c07c04bcc3ea1b3e7862421bc (
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
|
site_url = config["site_url"]
if not site_url then
Log.warning("site_url is not configured, using default")
site_url = ""
end
if not Regex.match(site_url, "(.*)/$") then
site_url = site_url .. "/"
end
links = HTML.select(page, "a")
index, link = next(links)
while index do
href = HTML.get_attribute(link, "href")
if href then
-- Check if URL starts with a leading "/"
if Regex.match(href, "^/") then
-- Remove leading slashes
href = Regex.replace(href, "^/*", "")
href = site_url .. href
HTML.set_attribute(link, "href", href)
end
end
index, link = next(links, index)
end
|