@arabold/docs-mcp-server 2.0.1 → 2.0.2

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
@@ -4407,9 +4407,11 @@ class DocumentPipeline extends BasePipeline {
4407
4407
  chunks: []
4408
4408
  };
4409
4409
  }
4410
- const extension = this.extractExtension(rawContent.source);
4410
+ const extension = this.extractExtension(rawContent.source, rawContent.mimeType);
4411
4411
  if (!extension) {
4412
- logger.warn(`Could not determine file extension: ${rawContent.source}`);
4412
+ logger.warn(
4413
+ `Could not determine file extension for ${rawContent.source} (MIME type: ${rawContent.mimeType})`
4414
+ );
4413
4415
  return {
4414
4416
  title: null,
4415
4417
  contentType: rawContent.mimeType,
@@ -4464,7 +4466,16 @@ class DocumentPipeline extends BasePipeline {
4464
4466
  };
4465
4467
  }
4466
4468
  }
4467
- extractExtension(source) {
4469
+ /**
4470
+ * Extracts file extension, trying multiple strategies:
4471
+ * 1. Use MIME type from rawContent (most reliable, from Content-Type header)
4472
+ * 2. Parse extension from URL/path
4473
+ */
4474
+ extractExtension(source, mimeType) {
4475
+ const extensionFromMime = this.getExtensionFromMimeType(mimeType);
4476
+ if (extensionFromMime) {
4477
+ return extensionFromMime;
4478
+ }
4468
4479
  try {
4469
4480
  const url = new URL(source);
4470
4481
  return this.getExtensionFromPath(url.pathname);
@@ -4472,9 +4483,23 @@ class DocumentPipeline extends BasePipeline {
4472
4483
  return this.getExtensionFromPath(source);
4473
4484
  }
4474
4485
  }
4486
+ /**
4487
+ * Gets file extension from MIME type using the mime package.
4488
+ */
4489
+ getExtensionFromMimeType(mimeType) {
4490
+ if (!mimeType || mimeType === "application/octet-stream") {
4491
+ return null;
4492
+ }
4493
+ return mime.getExtension(mimeType);
4494
+ }
4495
+ /**
4496
+ * Parses file extension from URL path or file path.
4497
+ * Strips query parameters and hash fragments, then extracts extension from the last path segment (filename).
4498
+ */
4475
4499
  getExtensionFromPath(pathStr) {
4476
- const lastSlash = pathStr.lastIndexOf("/");
4477
- const filename = lastSlash >= 0 ? pathStr.substring(lastSlash + 1) : pathStr;
4500
+ const cleanPath = pathStr.split("?")[0].split("#")[0];
4501
+ const lastSlash = cleanPath.lastIndexOf("/");
4502
+ const filename = lastSlash >= 0 ? cleanPath.substring(lastSlash + 1) : cleanPath;
4478
4503
  const lastDot = filename.lastIndexOf(".");
4479
4504
  if (lastDot > 0) {
4480
4505
  return filename.substring(lastDot + 1).toLowerCase();
@@ -12013,7 +12038,7 @@ const Layout = ({
12013
12038
  children,
12014
12039
  eventClientConfig
12015
12040
  }) => {
12016
- const versionString = version || "2.0.1";
12041
+ const versionString = version || "2.0.2";
12017
12042
  const versionInitializer = `versionUpdate({ currentVersion: ${`'${versionString}'`} })`;
12018
12043
  return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
12019
12044
  /* @__PURE__ */ jsxs("head", { children: [
@@ -14363,7 +14388,7 @@ class AppServer {
14363
14388
  try {
14364
14389
  if (telemetry.isEnabled()) {
14365
14390
  telemetry.setGlobalContext({
14366
- appVersion: "2.0.1",
14391
+ appVersion: "2.0.2",
14367
14392
  appPlatform: process.platform,
14368
14393
  appNodeVersion: process.version,
14369
14394
  appServicesEnabled: this.getActiveServicesList(),
@@ -18616,7 +18641,7 @@ function createCli(argv) {
18616
18641
  let globalEventBus = null;
18617
18642
  let globalTelemetryService = null;
18618
18643
  const commandStartTimes = /* @__PURE__ */ new Map();
18619
- const cli = yargs(hideBin(argv)).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("2.0.1").option("verbose", {
18644
+ const cli = yargs(hideBin(argv)).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("2.0.2").option("verbose", {
18620
18645
  type: "boolean",
18621
18646
  description: "Enable verbose (debug) logging",
18622
18647
  default: false
@@ -18676,7 +18701,7 @@ function createCli(argv) {
18676
18701
  if (shouldEnableTelemetry() && telemetry.isEnabled()) {
18677
18702
  const commandName = argv2._[0]?.toString() || "default";
18678
18703
  telemetry.setGlobalContext({
18679
- appVersion: "2.0.1",
18704
+ appVersion: "2.0.2",
18680
18705
  appPlatform: process.platform,
18681
18706
  appNodeVersion: process.version,
18682
18707
  appInterface: "cli",