Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect form.action due to incorrect base #59

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

mbland
Copy link
Owner

@mbland mbland commented Dec 18, 2023

With the base URL '/strcalc', resolving the form action URL './add' against document.location.href produces the path '/add', which is incorrect.

With the base URL '/strcalc/', resolving './add' produces '/strcalc/add' as expected.


Writing a test for this directly is difficult. (At least, it is at the component level using Vitest; an end-to-end Selenium test would catch it.) Tying the form action URL to a specific absolute path would render the component and its tests brittle. Also, it seems that trying to import the config from vite.config.js into a test (to access the config.base value) breaks the Vitest loader somehow.

As a proxy for a test assertion, the PageLoader constructor now enforces that the base path ends with '/' (before it enforced that it didn't).

With the base URL '/strcalc', resolving the form action URL './add'
against document.location.href produces the path '/add', which is
incorrect.

With the base URL '/strcalc/', resolving './add' produces
'/strcalc/add' as expected.

---

Writing a test for this directly is difficult. (At least, it is at the
component level using Vitest; an end-to-end Selenium test would catch
it.) Tying the form action URL to a specific absolute path would render
the component and its tests brittle. Also, it seems that trying to
import the config from vite.config.js into a test (to access the
config.base value) breaks the Vitest loader somehow.

As a proxy for a test assertion, the PageLoader constructor now enforces
that the base path ends with '/' (before it enforced that it _didn't_).
@mbland mbland self-assigned this Dec 18, 2023
@mbland mbland merged commit 71f43f1 into main Dec 18, 2023
3 checks passed
@mbland mbland deleted the fix-incorrect-form-action-due-to-incorrect-base branch December 18, 2023 17:24
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.

None yet

1 participant