docmd icon indicating copy to clipboard operation
docmd copied to clipboard

[Bug]: unable to load search index if base ends with /vX.Y.Z/

Open cboitel opened this issue 1 month ago • 2 comments

docmd version

0.9.8

Node.js version

v24.18.1

OS/Browser

macOS / Safari

Description

When I use url like http://localhost:3000/dir1/dir2/dir3/ and base /dir1/dir2/dir3/, everything works (access to pages, okf files generated...).

When dir3 is vX.Y.Z, pages are all ok but system fails to load search index since it tries to load it relative to /dir1/dir2/ instead of /dir1/dir2/vX.Y.Z/

When dir3 is a number 12345678, search works.

Steps to Reproduce

  1. dockmd init
  2. edit docmd.config.json to set url and base /dir1/dir2/vX.Y.Z/
  3. npm build
  4. deploy site under defined base
  5. enter the search zone and you get a "failed to load search index"

If base/url include vX.Y.Z, vX.Y.Z-preXX, browser fails to load search index since it tries to fetch it from /dir/dir2/_docmd-search/search-index.json instead of /dir1/dir2/vX.Y.Z/_docmd-search/search-index.json

Expected Behavior

Ensure in search plugin that any value provided for url and base are working

cboitel avatar Oct 21 '26 08:10 cboitel

Found possible culprit in plugin search code: https://github.com/docmd-io/docmd/blob/main/packages/plugins/search/src/client.ts#L74-L93

I guess this was done to handle a documentation being multi-version: my doc is mono-version but exposed on a path containing /vX.Y.Z

cboitel avatar Oct 21 '26 13:10 cboitel

Hi,

Thank you for reporting this issue.

This has been resolved in v0.9.9 via PR #266. Search index resolution now respects version-like directory prefixes without stripping base path segments.

mgks avatar Nov 04 '26 05:11 mgks