about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2014-10-10 09:14:30 +0100
committerAlan Pearce2014-10-10 09:14:30 +0100
commitbd5a901a5081d01df16ab3a750fdfa403391b3d2 (patch)
tree01dc65b765ac3f32f5e1f32a1951260cd8fe2977 /src
parentc773b522ebafbdfc9019898a83d74503700352e5 (diff)
downloadmicroformats-bd5a901a5081d01df16ab3a750fdfa403391b3d2.tar.lz
microformats-bd5a901a5081d01df16ab3a750fdfa403391b3d2.tar.zst
microformats-bd5a901a5081d01df16ab3a750fdfa403391b3d2.zip
Add helper function to get base URL
Diffstat (limited to 'src')
-rw-r--r--src/microformats/parser.clj9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index ba07fcf..e3a244e 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -65,6 +65,15 @@
        (apply str)
        str/trim))
 
+(defn get-base-url
+  "Find the base-url of a document."
+  [document]
+  (-> document
+      (html/select [:head :> [:base (html/attr? :href)]])
+      first
+      :attrs
+      :href))
+
 (defn get-value-class
   "Get the value class of elements"
   [elements]