Skip to content

Commit 7b9e061

Browse files
committed
1 parent 90d4927 commit 7b9e061

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎src/Paket.Core/Versioning/PackageSources.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ type PackageSource =
150150
#endif
151151
LocalNuGet(source,None)
152152
else
153-
if String.endsWithIgnoreCase "v3/index.json" source then
153+
if Regex("/v3(?:/[-\w]+)?/index.json$").IsMatch source then
154154
NuGetV3 { Url = source; Authentication = auth }
155155
else
156156
NuGetV2 { Url = source; Authentication = auth }

‎tests/Paket.Tests/Paket.Tests.fsproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<Paket>True</Paket>
7777
<Link>FsUnit.fs</Link>
7878
</Compile>
79+
<Compile Include="Versioning\PackageSourceSpecs.fs" />
7980
<None Include="paket.references" />
8081
<Compile Include="AssemblyInfo.fs" />
8182
<Compile Include="TestHelpers.fs" />
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module Paket.PackageSourceSpecs
2+
3+
open Paket
4+
open NUnit.Framework
5+
open FsUnit
6+
open Paket.Domain
7+
open Paket.PackageSources
8+
9+
[<TestCase("https://nuget.org/api/v2")>]
10+
[<TestCase("https://nuget.org/api/v2/")>]
11+
[<TestCase("https://www.myget.org/F/roslyn-tools/")>]
12+
[<TestCase("http://my.domain/artifactory/api/nuget/nugetsource/")>]
13+
[<TestCase("http://my.domain/artifactory/api/nuget/nuget-local/")>]
14+
[<TestCase("http://my.domain/artifactory/api/nuget/nuget_proxy/")>]
15+
let ``should parse known nuget2 source``(feed : string) =
16+
let line = sprintf "source %s" feed
17+
match PackageSource.Parse(line) with
18+
| NuGetV2 { Url = source; Authentication = _ } ->
19+
let quoted = sprintf "source \"%s\"" feed
20+
match PackageSource.Parse(quoted) with
21+
| NuGetV2 { Url = qsource; Authentication = _ } ->
22+
source |> shouldEqual qsource
23+
| _ -> failwith quoted
24+
| _ -> failwith feed
25+
26+
[<TestCase("https://api.nuget.org/v3/index.json")>]
27+
[<TestCase("https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json")>]
28+
[<TestCase("http://my.domain/artifactory/api/nuget/v3/nugetsource/index.json")>]
29+
[<TestCase("http://my.domain/artifactory/api/nuget/v3/nuget-local/index.json")>]
30+
[<TestCase("http://my.domain/artifactory/api/nuget/v3/nuget_proxy/index.json")>]
31+
let ``should parse known nuget3 source``(feed : string) =
32+
let line = sprintf "source %s" feed
33+
match PackageSource.Parse(line) with
34+
| NuGetV3 { Url = source; Authentication = _ } ->
35+
let quoted = sprintf "source \"%s\"" feed
36+
match PackageSource.Parse(quoted) with
37+
| NuGetV3 { Url = qsource; Authentication = _ } ->
38+
source |> shouldEqual qsource
39+
| _ -> failwith quoted
40+
| _ -> failwith feed

0 commit comments

Comments
 (0)