From d526deb99e44f2a8d1a9c3eea60676703dd64302 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 13 Aug 2023 17:42:34 +0200 Subject: Add mailcap, mime.types & misc refactorings * add mailcap: works with copiousoutput, needsterminal, etc. * add mime.types (only works with mailcap) * refactor pipeBuffer * remove "dispatcher" * fix bug in directory display where baseurl would not be used --- src/html/dom.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/html') diff --git a/src/html/dom.nim b/src/html/dom.nim index 11254c56..c0dc066c 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -27,10 +27,10 @@ import js/timeout import types/blob import types/color import types/matrix -import types/mime import types/referer import types/url import types/vector +import utils/mimeguess import utils/twtstr type @@ -794,6 +794,7 @@ const ReflectTable0 = [ # Forward declarations func attrb*(element: Element, s: string): bool proc attr*(element: Element, name, value: string) +func baseURL*(document: Document): URL proc tostr(ftype: enum): string = return ($ftype).split('_')[1..^1].join("-").tolower() @@ -1802,8 +1803,8 @@ func target0*(element: Element): string = # HTMLHyperlinkElementUtils (for and ) func href0[T: HTMLAnchorElement|HTMLAreaElement](element: T): string = if element.attrb("href"): - let url = parseUrl(element.attr("href"), some(element.document.url)) - if url.issome: + let url = parseURL(element.attr("href"), some(element.document.baseURL)) + if url.isSome: return $url.get # @@ -2030,7 +2031,7 @@ func isHostIncludingInclusiveAncestor*(a, b: Node): bool = return true return false -func baseURL*(document: Document): Url = +func baseURL*(document: Document): URL = #TODO frozen base url... var href = "" for base in document.elements(TAG_BASE): -- cgit 1.4.1-2-gfad0