Skip to content

Commit 6034c6a

Browse files
committed
NuGet: isHosted should only match hostname
1 parent da8bef9 commit 6034c6a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Tasks/Common/nuget-task-common/NuGetToolRunner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {ToolRunner, IExecOptions, IExecResult} from 'vsts-task-lib/toolrunner';
66
import * as auth from "./Authentication"
77
import * as os from 'os';
88
import * as path from 'path';
9+
import * as url from 'url';
910

1011
interface EnvironmentDictionary { [key: string]: string }
1112

@@ -160,7 +161,8 @@ function isHosted(): boolean {
160161
// not an ideal way to detect hosted, but there isn't a variable for it, and we can't make network calls from here
161162
// due to proxy issues.
162163
const collectionUri = tl.getVariable("System.TeamFoundationCollectionUri");
163-
return /\.visualstudio\.com$/i.test(collectionUri);
164+
const parsedCollectionUri = url.parse(collectionUri);
165+
return /\.visualstudio\.com$/i.test(parsedCollectionUri.hostname);
164166
}
165167

166168
// Currently, there is a race condition of some sort that causes nuget to not send credentials sometimes

0 commit comments

Comments
 (0)