Problem/Motivation

Add the ability to specify an external url for both the 'path' and 'replacement' of a URL Override.

Steps to reproduce

Specifying an external url in the replacement field of a urlOverride will end up getting 'skipped' in the current implementation.

Proposed resolution

Rework the URL Override feature to support external urls (it _could_ also be used to update a url w/o the additional checking; implying something that isn't managed by the Drupal site, but is accessible using the base url/host)

Remaining Tasks

  • Support the new urlOverride options for Rich Text Fields (processAnchorTags)
  • Support the new urlOverride options for Link fields

User interface changes

Additional options for Url Overrides on the settings page.
Updates the 'Media Lookup Order' section to use a dropdown to select plugins (rather than a textfield).
Adds 'Content Lookup Order' section to select plugins related to finding content (previously not configurable and not implemented as plugins)

API changes

Previously, the urlOverride function was only for use w/ urls on the site; once complete, it will support specifying urls that are external or not managed by Drupal.

Testing

Create a page with the following links (or similar) in the rich body field:

<p><a href="https://google.com">Google</a></p>
<p><a href="google.com">Google (missing scheme)</a></p>
<p><a href="/path/1">path 1:a</a></p>
<p><a href="/path/1?test=1">path 1:b</a></p>
<p><a href="/path/1?test=2&field=1">path 1:c</a></p>
<p><a href="/path/1#fragment">path 1:d</a></p>
<p><a href="/path/1?test=3#fragment">path 1:e</a></p>
<p><a href="/path/2">path 2:a</a></p>
<p><a href="/path/2?test=1">path 2:b</a></p>
<p><a href="/path/2?test=2&field=1">path 2:c</a></p>
<p><a href="/path/2#fragment">path 2:d</a></p>
<p><a href="/path/2?test=3#fragment">path 2:e</a></p>
<p><a href="/path/3">path 3:a</a></p>
<p><a href="/path/3?test=1">path 3:b</a></p>
<p><a href="/path/3?test=2&field=1">path 3:c</a></p>
<p><a href="/path/3#fragment">path 3:d</a></p>
<p><a href="/path/3?test=3#fragment">path 3:e</a></p>
<p><a href="/path/4">path 4:a</a></p>
<p><a href="/path/4?test=1">path 4:b</a></p>
<p><a href="/path/4?test=2&field=1">path 4:c</a></p>
<p><a href="/path/4#fragment">path 4:d</a></p>
<p><a href="/path/4?test=3#fragment">path 4:e</a></p>
<p><a href="/path/5">path 5:a</a></p>
<p><a href="/path/5?test=1">path 5:b</a></p>
<p><a href="/path/5?test=2&field=1">path 5:c</a></p>
<p><a href="/path/5#fragment">path 5:d</a></p>
<p><a href="/path/5?test=3#fragment">path 5:e</a></p>

The same links should be added in the Link field (except for the 'google.com' one, which is invalid in a link field).

Add settings in Link Magician in UrlOverride section (leave the "Keep ..." checkboxes at the default unless listed and make sure the 'enabled' is checked):

  • Path: https://google.com
    Replacement: https://www.google.com
    External is checked
  • Path: google.com
    Replacement: https://www.google.com
    External is checked
  • Path: /path/1
    Replacement: /page/1
    External is unchecked
  • Path: /path/2
    Replacement: /page/2
    External is unchecked
    "Keep URL Fragment" is unchecked
  • Path: /path/3
    Replacement: /page/3
    External is unchecked
    "Keep URL Query Parameters" is unchecked
  • Path: /path/4
    Replacement: /page/4
    External is unchecked
    Both "Keep ..." checkboxes are unchecked
  • Path: /path/5
    Replacement: https://www.externalsite.com
    External is checked

If you're using ddev, you may want to make a snapshot.

Run tidy on the node (or nodes) you created for the above. drush link_magician:tidy nodeid --nodeid={NNN}
Check the results report: there should be 13 updates.

Add 4 additional pages (and content type you can set a url alias for):
/page/1
/page/2
/page/3
/page/4

Check the results report: there should be 40 updates.
Updates to "/page/1" should retain query parameter and fragment where present.
Updates to "/page/2" should retain the query parameter(s) but fragment is removed.
Updates to "/page/3" should retain the fragment, but query parameter(s) is(are) removed.
Updates to "/page/4" drops both the fragment and query parameters.
The /path/5 update is now an external link.

I've attached the csv report from my local testing as an example. (note: this one has results included for the 4 additional pages included)

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

jasongose created an issue. See original summary.

jasongose’s picture

Issue summary: View changes

jasongose’s picture

Issue summary: View changes
jasongose’s picture

Issue summary: View changes
jasongose’s picture

Issue summary: View changes
jasongose’s picture

Issue summary: View changes
jasongose’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new8.89 KB
jasongose’s picture

Issue summary: View changes
StatusFileSize
new10.6 KB
jastraat’s picture

Status: Needs review » Reviewed & tested by the community

This worked great!

Url replacement worked great for internal and external links in both link and text fields.

jasongose’s picture

Status: Reviewed & tested by the community » Fixed

Merged :)

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.