From 076fac9cf431eec28fc4fdf17618138bae4ab98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kris=20Kr=C3=BCg?= <140290088+WalksWithASwagger@users.noreply.github.com> Date: Fri, 31 Jul 2026 03:35:27 +0000 Subject: [PATCH] fix(varlock): allow root / with url(noTrailingSlash=true) Docs and the VS Code diagnostics already exempt pathname `/`. Runtime was using val.endsWith('/'), which rejected https://example.com/. --- .bumpy/fix-url-no-trailing-slash-root.md | 5 +++++ packages/varlock/src/env-graph/lib/data-types.ts | 3 ++- packages/varlock/src/env-graph/test/data-types.test.ts | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .bumpy/fix-url-no-trailing-slash-root.md diff --git a/.bumpy/fix-url-no-trailing-slash-root.md b/.bumpy/fix-url-no-trailing-slash-root.md new file mode 100644 index 000000000..c3e4e9dd1 --- /dev/null +++ b/.bumpy/fix-url-no-trailing-slash-root.md @@ -0,0 +1,5 @@ +--- +varlock: patch +--- + +Allow root / with url(noTrailingSlash=true) diff --git a/packages/varlock/src/env-graph/lib/data-types.ts b/packages/varlock/src/env-graph/lib/data-types.ts index ecf7fb680..4b7dfa206 100644 --- a/packages/varlock/src/env-graph/lib/data-types.ts +++ b/packages/varlock/src/env-graph/lib/data-types.ts @@ -409,7 +409,8 @@ const UrlDataType = createEnvGraphDataType( ) { errors.push(new ValidationError(`Domain (${url.host}) is not in allowed list: ${settings.allowedDomains.join(',')}`)); } - if (settings?.noTrailingSlash && val.endsWith('/')) { + // Docs + vscode exempt root pathname `/` (https://example.com/ is OK). + if (settings?.noTrailingSlash && url.pathname.endsWith('/') && url.pathname !== '/') { errors.push(new ValidationError('URL must not have a trailing slash')); } if (settings?.matches) { diff --git a/packages/varlock/src/env-graph/test/data-types.test.ts b/packages/varlock/src/env-graph/test/data-types.test.ts index 2aac08f93..68f208f7b 100644 --- a/packages/varlock/src/env-graph/test/data-types.test.ts +++ b/packages/varlock/src/env-graph/test/data-types.test.ts @@ -82,12 +82,12 @@ describe('url data type', () => { expect(g.configSchema.MY_URL.isValid).toBe(false); }); - it('rejects bare domain with trailing slash', async () => { + it('accepts root URL with trailing slash', async () => { const g = await loadAndResolve(outdent` # @type=url(noTrailingSlash=true) MY_URL=https://example.com/ `); - expect(g.configSchema.MY_URL.isValid).toBe(false); + expect(g.configSchema.MY_URL.isValid).toBe(true); }); it('accepts bare domain without trailing slash', async () => {