fix segmentation fault

for urls containing '~' right after first depth of path,
e.g. '/test~test'
diff --git a/src/backend.c b/src/backend.c
index 0ab73b6..c219747 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -283,9 +283,11 @@
 						}
 					}
 					else if (c == '~') {
-						memcpy(buf + buflen, p, end - p);
-						buflen += (end - p);
-						break;
+						if (orig_start != start) {
+						  memcpy(buf + buflen, p, end - p);
+						  buflen += (end - p);
+						  break;
+						}
 					}
 					end++;
 				}