Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit 9f1648f

Browse files
kgybelswhoisj
authored andcommitted
Handle username with domain
Extend solution for #587 to also handle: username=DOMAIN\username
1 parent 5d9d62d commit 9f1648f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Cli-CredentialHelper.Test/OperationArgumentsTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,34 @@ public void EmailAsUserName()
121121
Assert.Equal(expected, actual, StringComparer.Ordinal);
122122
}
123123

124+
[Fact]
125+
public void UsernameWithDomain()
126+
{
127+
var input = new InputArg
128+
{
129+
Host = "example.visualstudio.com",
130+
Password = "incorrect",
131+
Path = "path",
132+
Protocol = Uri.UriSchemeHttps,
133+
Username = @"DOMAIN\username"
134+
};
135+
136+
OperationArguments cut;
137+
using (var memory = new MemoryStream())
138+
using (var writer = new StreamWriter(memory))
139+
{
140+
writer.Write(input.ToString());
141+
writer.Flush();
142+
143+
memory.Seek(0, SeekOrigin.Begin);
144+
145+
cut = new OperationArguments(memory);
146+
}
147+
148+
Assert.Equal(@"https://DOMAIN\[email protected]/path", cut.TargetUri.ToString(), StringComparer.Ordinal);
149+
Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal);
150+
}
151+
124152
[Fact]
125153
public void CreateTargetUriGitHubSimple()
126154
{

Cli-Shared/OperationArguments.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ private static bool NeedsToBeEscaped(string value)
543543
{
544544
case ':':
545545
case '/':
546+
case '\\':
546547
case '?':
547548
case '#':
548549
case '[':

0 commit comments

Comments
 (0)