Set the decision and its input
The supplied mount is /staff/. Relative app.js resolves to /staff/app.js when that mount supplies its base; root base instead yields /app.js outside it. An explicitly root-relative /app.js remains outside even after the base is corrected.
| Case | Input JSON |
|---|---|
| Base test | {"mount":"/staff/","reference":"app.js"} |
Run the supplied comparison
Actual URL resolution uses synthetic .invalid labels without requesting them. A resolved address does not prove hosting availability.
| Path | Output JSON |
|---|---|
| Faulty path | {"pathname":"/app.js","insideMount":false} |
| Required path | {"pathname":"/staff/app.js","insideMount":true} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(i.mount===null)return {held:true};
const resolved=new URL(i.reference,'https://local.example.invalid'+(corrected?i.mount:'/'));
return {pathname:resolved.pathname,insideMount:resolved.pathname.startsWith(i.mount)};
};
const cases=[{"input":{"mount":"/staff/","reference":"app.js"},"corrected":false,"expected":{"pathname":"/app.js","insideMount":false}},{"input":{"mount":"/staff/","reference":"app.js"},"corrected":true,"expected":{"pathname":"/staff/app.js","insideMount":true}},{"input":{"mount":"/staff/","reference":"/app.js"},"corrected":true,"expected":{"pathname":"/app.js","insideMount":false}},{"input":{"mount":null,"reference":"app.js"},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
The root-relative boundary prevents treating every reference as repaired by one base change. Missing mount remains held.
- Read the declared mount
- Resolve against its base
- Check the resulting path
Path resolution cannot certify a real hosting service.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| root-relative reference escapes subpath | {"mount":"/staff/","reference":"/app.js"} | {"pathname":"/app.js","insideMount":false} |
| mount not supplied | {"mount":null,"reference":"app.js"} | {"held":true} |
Which path belongs to the repaired base app.js?
Show the worked answer
/staff/app.js within the mount. /app.js remains a different destination outside the supplied subpath.