diff options
-rw-r--r-- | src/microformats/parser.clj | 9 | ||||
-rw-r--r-- | test/microformats/parser_expectations.clj | 3 |
2 files changed, 12 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] diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index 1c6d4f1..7344fde 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/microformats/parser_expectations.clj @@ -51,6 +51,9 @@ <p><a class=\"h-org\"></a></p> </div>")))) +(expect "http://example.com" + (get-base-url (snippet "<head><base href=\"http://example.com\"></head>"))) + (expect {:name '("Name")} (parse-p (snippet "<p class=\"p-name\"><span class=\"value\">Name</span></p>"))) |