Problem/motivation
When building the Link URL path, Linkit doesn't take into consideration subdirectory-based websites (e.g., www.example.com/mysite/) and creates an incorrect path. For example, '/mysite/media/123' instead of '/media/123'.
Steps to reproduce
- Create a subdirectory-based website.
- Install and configure Linkit.
- Edit some content and insert a link.
- Browse for some content or media.
- Once selected, note that the path begins with the path of the website (e.g., '/mysite').
Proposed resolution
The base_path needs to be trimmed from the path.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | linkit-fix-path-for-subdir-sites-3614654-4.patch | 824 bytes | jonathan_w |
Issue fork linkit-3614654
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jonathan_wComment #4
jonathan_wAlright, I've added a patch in MR !178. Unfortunately, it looks like the pipeline is failing due to issues in other files. I'm including a patch file here with the same changes.
Comment #5
jonathan_wComment #7
mark_fullmerIt looks to me like the failure is due to the proposed change. Specifically, there is a test that checks that the URL generated in a link field matches the value when the same URL is converted into a string, and so it is "failing" here, and failing on Gitlab CI when not failing locally because Drupal's Gitlab CI tests are set up to use a
On the surface, it seems reasonable that for relative URLs, the subdirectory should be removed. However, in scenarios where an absolute URL is generated, we'd want to make sure this isn't a problem. We do have test coverage for absolute URLs in
/tests/src/Kernel/Matchers/NodeMatcherTest.phpfor this, so that should give us a sense if this change would have any adverse effects.Comment #8
jonathan_wOh, sorry, I didn't even see that error. The interface displayed an error mentioning some errors like injection issues in the Linkit.php file and I didn't bother digging any deeper. Whoops!