Behaviour SwRS-MDOKFSTUDIO-FMSCHEMA-050
Links resolve from the configured or default root and stay inside it
When a link annotation has the resolution `document-relative`, `bundle-relative`, `bundle-relative-stem` or `project-relative`, the extension SHALL resolve the target from the folder of the document, the bundle root or the project root respectively, refuse an absolute target, and accept the target only when it names an existing file inside that root, a document-relative target being limited to the workspace folders unless `allowOutsideWorkspaceLinks` is true; a non-empty markdownOkfSchemaStudio.frontmatter.bundleRoot or projectRoot replaces the default root, a relative path being taken from the first workspace folder, and markdownOkfSchemaStudio.frontmatter.allowOutsideWorkspaceLinks decides whether a document-relative link may leave every workspace folder.
Step 2 of path 1 in StRS-MDOKFSTUDIO-FMSCHEMA-014: from “The link target is checked against the files” to “The link is shown pending, then resolved”.
Scenarios 11
The situations the tests check; open one to read it.
nominalTargets that resolve from their root
| Resolution | Setup | Outcome |
|---|
| document-relative | Link t.md and t.md in the document's folder | The link is valid |
| bundle-relative | A bundle root holding docs/t.md and the value docs/t.md | The link is valid |
| bundle-relative-stem | The same bundle root and the value docs/t (`.md` is added to the target for the stem form) | The link is valid |
| project-relative | A project root and the value bundle/docs/t.md naming an existing file below it | The link is valid |
nominalDefault bundle and project roots
| Setting | Layout | Outcome |
|---|
| `markdownOkfSchemaStudio.frontmatter.bundleRoot` empty | A schema folder bundle/_schema, a document in bundle/docs and a file bundle/index.md (`log.md` serves too) | A bundle-relative link resolves from the bundle folder: the parent of the schema folder is the bundle root when it contains the document and an `index.md` or `log.md` |
| `markdownOkfSchemaStudio.frontmatter.projectRoot` empty | A `.git` entry in a workspace folder above the document | A project-relative link resolves from the folder holding `.git`: the nearest folder with a `.git` entry above the document is the project root when it lies inside a workspace folder |
refusalMissing file
Givena document-relative link nope.md that does not exist
Whenthe document is analysed
Thenthe field carries [E10] target 'nope.md' does not resolve to a file at 'ref' and the label reads File not found
refusalAbsolute target
| Value | Resolution | Outcome |
|---|
| /etc/hosts (POSIX) | any | [E10] absolute target '/etc/hosts' is not allowed at 'ref'; label Absolute paths are not allowed |
| C:/x.md (drive letter) | any | The same refusal is reported for the drive-letter path |
| A target starting with two backslashes (UNC) | any | Refused as UNC with the same error |
refusalBundle or project target leaves its root
| Input | Outcome |
|---|
| A bundle-relative value ../outside.md | [E10] target '../outside.md' escapes its bundle-relative root at 'ref'; label Outside the allowed folder |
| A file inside the root that is a symbolic link to a file outside it | Refused with the same kind of error ("escapes its {resolution} root") |
| A project-relative value that resolves outside the project root | Refused with the E10 error "escapes its project-relative root" |
boundaryRoot unavailable
| Input | Outcome |
|---|
| A bundle-relative link, no configured bundle root, and no `index.md` or `log.md` in the parent of the schema folder | [W15] Skipped file-link check at 'ref': bundle-relative root is unavailable; label Link root unavailable |
| A project-relative link, no configured project root, and no folder with a `.git` entry above the document inside a workspace folder | The same warning W15 with "project-relative root is unavailable" |
| A project-relative link, no configured project root, and the nearest `.git` lies above the workspace folders | The same warning: an auto-detected git root outside the workspace is ignored |
nominalConfigured root
| Setting | Value | Link | Outcome |
|---|
| bundleRoot | bundle | A bundle-relative link docs/t.md | The link resolves from the bundle folder |
| projectRoot | The workspace folder | A project-relative link bundle/docs/t.md | The link is valid |
refusalConfigured root that cannot be used
| Setting | Value | Outcome |
|---|
| bundleRoot | A folder that does not exist | The field carries the warning W15 "bundle-relative root is unavailable", with no fall back to the convention root |
| projectRoot | A folder that does not exist | The field carries the warning W15 "project-relative root is unavailable", with no fall back to the git root |
| either | Any value that is not a folder | Treated as unavailable, with the same warning |
boundaryAccepted values of the settings
| Setting | Rule |
|---|
| bundleRoot, projectRoot | String, default empty string; the value is trimmed; a relative path is taken from the first workspace folder; an absolute path is used as it is |
| allowOutsideWorkspaceLinks | Boolean, default false; only document-relative links are affected by it |
refusalallowOutsideWorkspaceLinks false
Givena document-relative link ../../outside.md whose target is outside the workspace folder and the setting at its default false
Whenthe document is analysed
Thenthe field carries [E10] target '../../outside.md' escapes its navigation root at 'ref' and the label reads Outside the allowed folder
nominalallowOutsideWorkspaceLinks true or target inside the workspace
| Setting | Link | Outcome |
|---|
| false | A document-relative link to a file inside the workspace folder | The link is valid |
| true | The link ../../outside.md whose target is outside the workspace folder | The link is valid and navigating to it is allowed |
| true | A bundle-relative link ../outside.md | The link is still refused as escaping its bundle-relative root |
Known limits (2)
- a configured bundle root that does not exist is reported exactly like a missing convention root, without naming the setting.
- one projectRoot value serves the whole workspace, so nested bundles cannot each have their own root, and the message does not name the root that was tried.