Commit Diff
Diff:
d73d0e1bd102954594fa2d2a51975d90127bf53f
3adf60f83646a91b0eee3026a98a4567077d8304
Commit:
3adf60f83646a91b0eee3026a98a4567077d8304
Tree:
aa19ac8471b0b19422e96eeda827eba1e00188fa
Author:
Omar Polo <op@omarpolo.com>
Date:
Thu Dec 2 14:40:15 2021 UTC
Message:
correctly extract the title
commit - d73d0e1bd102954594fa2d2a51975d90127bf53f
commit + 3adf60f83646a91b0eee3026a98a4567077d8304
blob - ab1db5254324e85488fb55a83a9b76b1e3ba2673
blob + 6a0ffd36c583db64939b566da8a7a7160e2c1446
--- main.go
+++ main.go
@@ -104,10 +104,24 @@ func messageTooLong(conn *irc.Conn, line *irc.Line) {
}
}
+func stringifyNode(node *html.Node) string {
+ s := ""
+
+ if node.Type == html.TextNode {
+ return node.Data
+ }
+
+ for child := node.FirstChild; child != nil; child = child.NextSibling {
+ s += stringifyNode(child)
+ }
+
+ return s
+}
+
func getPageTitle(node *html.Node) string {
for child := node.FirstChild; child != nil; child = child.NextSibling {
if child.Type == html.ElementNode && child.Data == "title" {
- text := node.FirstChild.Data
+ text := stringifyNode(node)
return strings.Trim(text, " \t\n")
}
}
Omar Polo