 index 000000000..c66df924b
 --- /dev/null
 +++ b/lib/pathtools.c
-@@ -0,0 +1,533 @@
+@@ -0,0 +1,539 @@
 +/*
 +      .Some useful path tools.
 +        .ASCII only for now.

 configure.ac         |   1 +
 lib/Makefile.inc     |   5 +-
 lib/curl_config.h.in |   3 +
 lib/pathtools.c      | 533 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/pathtools.h      |  53 +++++
 lib/url.c            |  26 ++-
 6 files changed, 618 insertions(+), 3 deletions(-)
 create mode 100644 lib/pathtools.c
 create mode 100644 lib/pathtools.h


+  size_t in_size = strlen (path);
+  int it_ended_with_a_slash = (path[in_size - 1] == '/') ? 1 : 0;
+  char * result = path;
+  char * result_p;
+  char const ** toks;
+  if (path[0] == '/' && path[1] == '/') {
+    /* preserve UNC path */
+    path++;
+    in_size--;
+    result++;
+  }
+  sanitise_path(result);
+  char * result_p = result;
+
