Skip to content

path-settings

This module provides classes and validators for managing include/exclude path settings.

An entry takes one of three forms, and every form matches case-insensitively:

  • A regular expression literal, /pattern/flags. Its own flags are honoured and i is always added. g and y are accepted and dropped, since they make RegExp.test stateful and say nothing about which paths match. - A glob, an entry holding an unescaped *, ? or [. * matches within one path segment, ** across segments, ? one character and [abc] / [!abc] a character class. A glob with no / matches a file or folder NAME at any depth, as in .gitignore (*.pdf matches a/b/c.pdf); one with a / is anchored to the vault root (Attachments/*.pdf). A trailing / makes it match folders only. - A plain path, every other entry, which matches that path and everything inside it. A literal *, ?, [ or \ in a plain path or a glob is written escaped (\*).
Class Description
PathSettings A class for managing include/exclude path settings. See the module documentation for the entry syntax: plain paths, globs and regular expression literals, all matched case-insensitively.
Function Description
pathsValidator Validates include/exclude path entries, reporting the first entry that is not a valid regular expression or glob. An invalid entry does not throw when assigned to PathSettings — the whole list falls back to its default pattern instead — so this validator is what surfaces the problem to the user. The message names the entry and the reason it is invalid.