com.jimuwd.xian.registry-proxy 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -143,7 +143,7 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
143
143
  return;
144
144
  }
145
145
  const fullUrl = new URL(req.url, `${proxyConfig.https ? 'https' : 'http'}://${req.headers.host}`);
146
- if (basePathPrefixedWithSlash && !fullUrl.pathname.startsWith(basePathPrefixedWithSlash)) {
146
+ if (!fullUrl.pathname.startsWith(basePathPrefixedWithSlash)) {
147
147
  console.error(`Path ${fullUrl.pathname} does not match basePath ${basePathPrefixedWithSlash}`);
148
148
  res.writeHead(404).end('Not Found');
149
149
  return;
@@ -194,8 +194,8 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
194
194
  const originalSearchParamsStr = originalUrl.search || '';
195
195
  const tarballPathPrefixedWithSlash = removeRegistryPrefix(dist.tarball, registries);
196
196
  dist.tarball = `${proxyBaseUrlNoSuffixedWithSlash}${tarballPathPrefixedWithSlash}${originalSearchParamsStr}`;
197
- console.log("tarballPathPrefixedWithSlash", tarballPathPrefixedWithSlash);
198
- console.log("dist.tarballUrl", dist.tarball);
197
+ if (!tarballPathPrefixedWithSlash.startsWith("/"))
198
+ console.error("bad tarballPath, must be PrefixedWithSlash", tarballPathPrefixedWithSlash);
199
199
  }
200
200
  }
201
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.jimuwd.xian.registry-proxy",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "type": "module",
5
5
  "description": "A lightweight npm registry proxy with fallback support",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -180,7 +180,7 @@ export async function startProxyServer(
180
180
  ): Promise<HttpServer | HttpsServer> {
181
181
  const proxyConfig = await loadProxyConfig(proxyConfigPath);
182
182
  const registries = await loadRegistries(proxyConfigPath, localYarnConfigPath, globalYarnConfigPath);
183
- const basePathPrefixedWithSlash = proxyConfig.basePath ? `/${proxyConfig.basePath.replace(/^\/|\/$/g, '')}` : '/';
183
+ const basePathPrefixedWithSlash: string = proxyConfig.basePath ? `/${proxyConfig.basePath.replace(/^\/|\/$/g, '')}` : '/';
184
184
 
185
185
  console.log('Active registries:', registries.map(r => r.url));
186
186
  console.log('Proxy base path:', basePathPrefixedWithSlash);
@@ -196,7 +196,7 @@ export async function startProxyServer(
196
196
  }
197
197
 
198
198
  const fullUrl = new URL(req.url, `${proxyConfig.https ? 'https' : 'http'}://${req.headers.host}`);
199
- if (basePathPrefixedWithSlash && !fullUrl.pathname.startsWith(basePathPrefixedWithSlash)) {
199
+ if (!fullUrl.pathname.startsWith(basePathPrefixedWithSlash)) {
200
200
  console.error(`Path ${fullUrl.pathname} does not match basePath ${basePathPrefixedWithSlash}`);
201
201
  res.writeHead(404).end('Not Found');
202
202
  return;
@@ -249,8 +249,7 @@ export async function startProxyServer(
249
249
  const originalSearchParamsStr = originalUrl.search || '';
250
250
  const tarballPathPrefixedWithSlash = removeRegistryPrefix(dist.tarball, registries);
251
251
  dist.tarball = `${proxyBaseUrlNoSuffixedWithSlash}${tarballPathPrefixedWithSlash}${originalSearchParamsStr}`;
252
- console.log("tarballPathPrefixedWithSlash", tarballPathPrefixedWithSlash);
253
- console.log("dist.tarballUrl", dist.tarball);
252
+ if (!tarballPathPrefixedWithSlash.startsWith("/")) console.error("bad tarballPath, must be PrefixedWithSlash", tarballPathPrefixedWithSlash);
254
253
  }
255
254
  }
256
255
  }