 +  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;
 +

+    *path_p = '/';
+  }
+  /* Replace any '//' with '/' */
+  path_p = path + !!*path; /* skip first character, if any, to handle UNC paths correctly */
+  while ((path_p = strstr (path_p, "//")) != NULL)
+  {
+    memmove (path_p, path_p + 1, path_size--);

 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

