Problem/Motivation

Links with 'absolute' => TRUE get rendered as 'http://localhost/system-test/method' for example.

Encountered in #3517299: Convert functional tests in help module to kernel tests.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

joachim created an issue. See original summary.

joachim’s picture

This is because UrlGenerator gets 'localhost' as the host from RequestContext.

I imagine that Kernel tests needing to see absolute links will need to mock the RequestContext.

joachim’s picture

Hmm though actually, I don't think an absolute link will work in the HttpKernelBrowser.

What we might need to do instead is in HttpKernelUiHelperTrait::drupalGet() is strip off an initial 'http://localhost' so that clicking an absolute link works.

joachim’s picture

Yup, simple fix for HttpKernelUiHelperTrait:

    if (str_starts_with($path, 'http://localhost')) {
      $path = substr($path, 16);
    }

Though this might be YAGNI - trying #3582386: remove absolute from HelpTwigExtension links first.

joachim’s picture

This is probably a wontfix now that the Help module issue is getting done -- though should we add docs to HttpKernelUiHelperTrait::drupalGet() to say that absolute URLs won't work?

joachim’s picture

Status: Active » Closed (won't fix)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.