Skip to content

Commit d93a9bc

Browse files
committed
fix: check for dev.azure.com or visualstudio.com for cloud. otherwise use TFS login
1 parent 439078e commit d93a9bc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/MigrationTools.Clients.TfsObjectModel/Tools/TfsEmbededImagesTool.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,18 @@ private string UploadedAndRetrieveAttachmentLinkUrl(string matchedSourceUri, str
132132
{
133133
if (!string.IsNullOrEmpty(sourcePersonalAccessToken))
134134
{
135-
if (!string.IsNullOrEmpty(sourcePersonalAccessToken) && new Uri(matchedSourceUri).PathAndQuery.StartsWith("/tfs/"))
135+
var host = new Uri(matchedSourceUri).Host.ToLowerInvariant();
136+
if (host.Contains("dev.azure.com") || host.Contains("visualstudio.com"))
136137
{
137-
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", sourcePersonalAccessToken)));
138-
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
138+
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", sourcePersonalAccessToken);
139139
}
140-
else if (!string.IsNullOrEmpty(sourcePersonalAccessToken))
140+
else
141141
{
142-
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", sourcePersonalAccessToken);
142+
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", sourcePersonalAccessToken)));
143+
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
143144
}
144145
}
146+
145147
var result = DownloadFile(httpClient, matchedSourceUri, fullImageFilePath);
146148
if (!result.IsSuccessStatusCode)
147149
{

0 commit comments

Comments
 (0)