Skip to content

fix: normalize hostnames in version dropdown matching#1978

Open
Pittu-Sharma wants to merge 4 commits into
kyverno:mainfrom
Pittu-Sharma:fix/version-dropdown-matching
Open

fix: normalize hostnames in version dropdown matching#1978
Pittu-Sharma wants to merge 4 commits into
kyverno:mainfrom
Pittu-Sharma:fix/version-dropdown-matching

Conversation

@Pittu-Sharma
Copy link
Copy Markdown
Contributor

Related issue

#1929

Proposed Changes

When the Kyverno website is accessed via a hostname with a www. prefix (e.g., www.kyverno.io), the version dropdown incorrectly identifies the current documentation version as main instead of the latest stable release. This happens because the exact matching logic fails to recognize www.kyverno.io as an alias for the stable production site.

This PR resolves the issue by improving the version detection utility in src/utils/versions.ts:

  • It normalizes the current browser hostname by stripping the www. prefix and converting to lowercase.
  • It normalizes the hostnames defined in the documentationVersions list in the same manner.
  • It ensures that www.kyverno.io correctly maps to the canonical kyverno.io entry, while preserving the intended behavior for subdomains like main.kyverno.io and local development on localhost.

Checklist

  • I have read the contributing guidelines.
  • I have inspected the website preview for accuracy.
  • I have signed off my issue.

Signed-off-by: pittu sharma <pittusharma47@gmail.com>
This fix ensures that the version dropdown correctly identifies the current
documentation version when the site is accessed via 'www.kyverno.io' (or any
other hostname with a 'www.' prefix).

The matching logic now normalizes both the browser's current hostname and
the hostnames defined in the documentation versions list by stripping 'www.'
and converting to lowercase.

Fixes: kyverno#1929
Signed-off-by: pittu sharma <pittusharma47@gmail.com>
@welcome
Copy link
Copy Markdown

welcome Bot commented Apr 24, 2026

Thanks for opening your first Pull Request here! Please check out our Contributing guidelines and confirm that you Signed off.

@Pittu-Sharma
Copy link
Copy Markdown
Contributor Author

Thanks for opening your first Pull Request here! Please check out our Contributing guidelines and confirm that you Signed off.

Thanks! I have read the guidelines and confirmed that all my commits are signed off. The checks are passing.

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.

1 participant