summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xlib/pure/parseurl.nim18
-rwxr-xr-xlib/pure/parsexml.nim2
-rwxr-xr-xweb/news.txt2
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/pure/parseurl.nim b/lib/pure/parseurl.nim
new file mode 100755
index 000000000..cbb5ba9c9
--- /dev/null
+++ b/lib/pure/parseurl.nim
@@ -0,0 +1,18 @@
+import regexprs, strutils
+
+type
+  TUrl* = tuple[protocol, subdomain, domain, port: string, path: seq[string]]
+
+proc parseUrl*(url: string): TUrl =
+  #([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?
+  const pattern = r"([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?"
+  var m: array[0..6, string] #Array with the matches
+  discard regexprs.match(url, pattern, m)
+ 
+  result = (protocol: m[1], subdomain: m[2], domain: m[3] & m[4], 
+            port: m[5], path: m[6].split('/'))
+ 
+when isMainModule:
+  var r = parseUrl(r"http://google.com/search?var=bleahdhsad")
+  echo(r.domain)
+
diff --git a/lib/pure/parsexml.nim b/lib/pure/parsexml.nim
index 7184e6c45..343fabd8c 100755
--- a/lib/pure/parsexml.nim
+++ b/lib/pure/parsexml.nim
@@ -53,6 +53,8 @@ import
 
 # the parser treats ``<br />`` as ``<br></br>``
 
+##  xmlElementCloseEnd, ## ``/>`` 
+
 type 
   TXmlEventKind* = enum ## enumation of all events that may occur when parsing
     xmlError,           ## an error ocurred during parsing
diff --git a/web/news.txt b/web/news.txt
index bc8d5ff56..47a112a96 100755
--- a/web/news.txt
+++ b/web/news.txt
@@ -12,6 +12,8 @@ Bugfixes
 --------
 - The Posix version of ``os.copyFile`` has better error handling.
 - Fixed bug #502670 (underscores in identifiers).
+- Fixed a bug in the ``parsexml`` module concerning the parsing of
+  ``<tag attr="value" />``.
 
 
 Additions