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

  1. Create a subdirectory-based website.
  2. Install and configure Linkit.
  3. Edit some content and insert a link.
  4. Browse for some content or media.
  5. 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.

Issue fork linkit-3614654

Command icon 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

jonathan_w created an issue. See original summary.

jonathan_w’s picture

Version: 7.1.x-dev » 7.x-dev

jonathan_w’s picture

Assigned: jonathan_w » Unassigned
StatusFileSize
new824 bytes

Alright, 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.

jonathan_w’s picture

Issue summary: View changes

mark_fullmer made their first commit to this issue’s fork.

mark_fullmer’s picture

Unfortunately, it looks like the pipeline is failing due to issues in other files.

It 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

web/<code> subdirectory:

<code>1) Drupal\Tests\linkit\FunctionalJavascript\LinkFieldTest::testLinkFieldWidgetAndFormatter
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'/web/entity_test_mul/manage/1'
+'/entity_test_mul/manage/1'

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.php for this, so that should give us a sense if this change would have any adverse effects.

jonathan_w’s picture

Oh, 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!