Skip to content

Commit 70944ac

Browse files
committed
Release 1.3.0
1 parent d21f44c commit 70944ac

File tree

15 files changed

+1365
-60
lines changed

15 files changed

+1365
-60
lines changed

Add.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5-
using System.Net.Http;
65
using System.Text.RegularExpressions;
76
using System.Threading.Tasks;
87

@@ -11,11 +10,7 @@ namespace dotnet_unpkg
1110
public static class Add
1211
{
1312
private static readonly Regex DistInPath = new Regex(@"\/dist\/.*");
14-
private static readonly HttpClient Client = new HttpClient
15-
{
16-
BaseAddress = new Uri("https://unpkg.com")
17-
};
18-
13+
1914
private static readonly string BaseDirectory = Path.Combine("wwwroot", "lib");
2015

2116
public static async Task Run(IEnumerable<string> args)
@@ -78,7 +73,14 @@ private static Task DownloadPackage(string package, string basePath, IEnumerable
7873

7974
private static async Task DownloadFile(string package, string basePath, DistFile file)
8075
{
81-
var (cdn, localPath) = await Download.DistFile(package, $"{basePath.TrimSlashes()}/{file.Path.TrimSlashes()}");
76+
basePath = basePath.TrimSlashes();
77+
var path = file.Path.TrimSlashes();
78+
var pathSegments = path.Split('/');
79+
if (basePath.Split('/').LastOrDefault() == pathSegments.FirstOrDefault())
80+
{
81+
path = string.Join('/', pathSegments.Skip(1));
82+
}
83+
var (cdn, localPath) = await Download.DistFile(package, $"{basePath}/{path}");
8284
file.Url = cdn;
8385
file.LocalPath = localPath.Replace(Path.DirectorySeparatorChar, '/');
8486
}

0 commit comments

Comments
 (0)