From acc6bbe48a79ade937c30ff3da6b442b10c86945 Mon Sep 17 00:00:00 2001 From: "Nadya.Zabrodina" Date: Fri, 28 Dec 2012 01:18:17 +0400 Subject: [PATCH] Hg: refactor regexp in URL_WITH_PASSWORD. *Bug with url contains only login and without password fixed. --- plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java index defd85daa8fb..e6ef2fbfe0ca 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java @@ -47,7 +47,7 @@ import java.util.regex.Pattern; */ public abstract class HgUtil { - public static final Pattern URL_WITH_PASSWORD = Pattern.compile("(.+):(.+)@(.+)"); + public static final Pattern URL_WITH_PASSWORD = Pattern.compile("(?:.+)://(?:.+)(:.+)@(?:.+)"); //http(s)://username:password@url public static final int MANY_FILES = 100; private static final Logger LOG = Logger.getInstance(HgUtil.class); @@ -479,7 +479,7 @@ public abstract class HgUtil { public static String removePasswordIfNeeded(@NotNull String path) { Matcher matcher = URL_WITH_PASSWORD.matcher(path); if (matcher.matches()) { - return matcher.group(1) + "@" + matcher.group(3); + return path.substring(0, matcher.start(1)) + path.substring(matcher.end(1), path.length()); } return path; }