Skip to content

fix(domain/virtualhost): keep colons in --path-to-url values#1880

Merged
martin-helmich merged 1 commit into
mittwald:masterfrom
dkd-dobberkau:fix/virtualhost-path-to-url-colon-split
Jun 3, 2026
Merged

fix(domain/virtualhost): keep colons in --path-to-url values#1880
martin-helmich merged 1 commit into
mittwald:masterfrom
dkd-dobberkau:fix/virtualhost-path-to-url-colon-split

Conversation

@dkd-dobberkau

Copy link
Copy Markdown
Contributor

Fixes #1879.

--path-to-url "/:https://example.com" currently fails with Target.Url: Does not match format 'uri' because the value is split on every colon, so url ends up as "https".

This change splits on the first colon while preserving the rest:

const [path, ...urlParts] = pathToUrl.split(":");
const url = urlParts.join(":");

split(":", 2) would not work in JS — it drops the rest of the string. The destructure + join approach keeps the full URL, including any colons inside it (e.g. ports: https://backend.example.com:8080/v2).

Verification

  • yarn compile, yarn lint, prettier — all green.
  • yarn test:unit (full suite): 121 tests passing, no regressions.
  • Manual check of the parser logic against three realistic inputs:
/:https://redirect.example                       → path="/",    url="https://redirect.example"
/api:https://backend.example.com:8080/v2         → path="/api", url="https://backend.example.com:8080/v2"
/old:http://example.com                          → path="/old", url="http://example.com"
  • Verified end-to-end against the live Mittwald API (POST /v2/ingresses) that the resulting payload is accepted and the 301 redirect works.

No new unit test added — this command does not currently have unit-test coverage and the parsing is inline in exec(). Happy to extract a helper and add a test if maintainers prefer.

The value of --path-to-url was split on every colon, so the URL
portion after the protocol's "://" was dropped before the API
call. The API then rejected the truncated string with
"Target.Url: Does not match format 'uri'".

Split on the first colon while preserving the rest of the value,
matching the intent of the help text examples like
"/:https://redirect.example".

@martin-helmich martin-helmich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. 🤦‍♂️ Good catch, thanks. 👍

@martin-helmich martin-helmich enabled auto-merge (squash) June 3, 2026 08:16
@martin-helmich martin-helmich merged commit 2e30d12 into mittwald:master Jun 3, 2026
11 checks passed
mittwald-machine added a commit that referenced this pull request Jun 3, 2026
## [1.17.2](v1.17.1...v1.17.2) (2026-06-03)

### Bug Fixes

* **domain/virtualhost:** keep colons in --path-to-url values ([#1880](#1880)) ([2e30d12](2e30d12))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

domain virtualhost create --path-to-url splits URL on every colon, breaking all real URLs

2 participants