@@ -13,18 +13,8 @@ namespace BaGet.Core
13
13
14
14
public static class PackageArchiveReaderExtensions
15
15
{
16
- private static readonly string [ ] OrderedReadmeFileNames = new [ ]
17
- {
18
- "readme.md" ,
19
- "readme.txt" ,
20
- } ;
21
-
22
- private static readonly HashSet < string > ReadmeFileNames = new HashSet < string > (
23
- OrderedReadmeFileNames ,
24
- StringComparer . OrdinalIgnoreCase ) ;
25
-
26
16
public static bool HasReadme ( this PackageArchiveReader package )
27
- => package . GetFiles ( ) . Any ( ReadmeFileNames . Contains ) ;
17
+ => ! string . IsNullOrEmpty ( package . NuspecReader . GetReadme ( ) ) ;
28
18
29
19
public static bool HasEmbeddedIcon ( this PackageArchiveReader package )
30
20
=> ! string . IsNullOrEmpty ( package . NuspecReader . GetIcon ( ) ) ;
@@ -33,19 +23,13 @@ public async static Task<Stream> GetReadmeAsync(
33
23
this PackageArchiveReader package ,
34
24
CancellationToken cancellationToken )
35
25
{
36
- var packageFiles = package . GetFiles ( ) ;
37
-
38
- foreach ( var readmeFileName in OrderedReadmeFileNames )
26
+ var readmePath = package . NuspecReader . GetReadme ( ) ;
27
+ if ( readmePath == null )
39
28
{
40
- var readmePath = packageFiles . FirstOrDefault ( f => f . Equals ( readmeFileName , StringComparison . OrdinalIgnoreCase ) ) ;
41
-
42
- if ( readmePath != null )
43
- {
44
- return await package . GetStreamAsync ( readmePath , cancellationToken ) ;
45
- }
29
+ throw new InvalidOperationException ( "Package does not have a readme!" ) ;
46
30
}
47
31
48
- throw new InvalidOperationException ( "Package does not have a readme!" ) ;
32
+ return await package . GetStreamAsync ( readmePath , cancellationToken ) ;
49
33
}
50
34
51
35
public async static Task < Stream > GetIconAsync (
0 commit comments