Package
markdown-confluence-sync
What happened?
Files are silently skipped from sync if their filename merely ends with the parent directory name, even when they are not index files. This causes pages to be missing from Confluence with no error or warning.
Steps to reproduce
- Create a docs directory named
notes/
- Inside it, create a genuine index
index.md and also file named per-experiment-notes.md (any file whose name ends with notes)
- Run
markdown-confluence-sync in tree mode
per-experiment-notes.md is not synced to Confluence — only index.md is
Root cause
isNotIndexFile calls buildIndexFileRegExp with an empty string as the separator:
export function isNotIndexFile(path) {
const dirnamePath = basename(dirname(path));
const pattern = buildIndexFileRegExp("", dirnamePath); // ← sep is always ""
return !pattern.test(path);
}
export function buildIndexFileRegExp(sep, dirnamePath) {
const pathSep = sep === "\\" ? "\\\\" : sep; // "" stays ""
return new RegExp(pathSep + `(index|README|${dirnamePath}).mdx?$`);
}
The sep parameter only exists to escape backslashes for Windows in unit tests — it never injects an actual path separator when called from isNotIndexFile. The resulting regex for dirnamePath = "notes" is therefore:
/(index|README|notes).mdx?$/
This matches …/notes/per-experiment-notes.md because the full path string ends with notes.md. So isNotIndexFile returns false, isValidFile returns false, and the file is silently excluded. I suspect it would also match anything ending in index or README as well.
Expected behaviour
Only files whose full filename (not a suffix of it) matches index, README, or the directory name should be treated as index files. The simplest fix is to check the basename directly rather than testing the full path, and there's no need for as complex a regex:
export function isNotIndexFile(path) {
const name = basename(path).replace(/\.mdx?$/, "");
const dir = basename(dirname(path));
return !["index", "README", "Readme", dir].includes(name);
}
Version
2.x
Relevant log output
Code of Conduct
Package
markdown-confluence-sync
What happened?
Files are silently skipped from sync if their filename merely ends with the parent directory name, even when they are not index files. This causes pages to be missing from Confluence with no error or warning.
Steps to reproduce
notes/index.mdand also file namedper-experiment-notes.md(any file whose name ends withnotes)markdown-confluence-syncin tree modeper-experiment-notes.mdis not synced to Confluence — onlyindex.mdisRoot cause
isNotIndexFilecallsbuildIndexFileRegExpwith an empty string as the separator:The
sepparameter only exists to escape backslashes for Windows in unit tests — it never injects an actual path separator when called fromisNotIndexFile. The resulting regex fordirnamePath = "notes"is therefore:This matches
…/notes/per-experiment-notes.mdbecause the full path string ends withnotes.md. SoisNotIndexFilereturnsfalse,isValidFilereturnsfalse, and the file is silently excluded. I suspect it would also match anything ending inindexorREADMEas well.Expected behaviour
Only files whose full filename (not a suffix of it) matches
index,README, or the directory name should be treated as index files. The simplest fix is to check the basename directly rather than testing the full path, and there's no need for as complex a regex:Version
2.x
Relevant log output
Code of Conduct