diff --git a/src/url-toolkit.js b/src/url-toolkit.js
index <HASH>..<HASH> 100644
--- a/src/url-toolkit.js
+++ b/src/url-toolkit.js
@@ -3,7 +3,7 @@
 (function (root) {
   var URL_REGEX =
     /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;
-  var FIRST_SEGMENT_REGEX = /^([^\/?#]*)([^]*)$/;
+  var FIRST_SEGMENT_REGEX = /^(?=([^\/?#]*))\1([^]*)$/;
   var SLASH_DOT_REGEX = /(?:\/|^)\.(?=\/)/g;
   var SLASH_DOT_DOT_REGEX = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;
make FIRST_SEGMENT_REGEX safe