This module provides a tool to extract the final destination link from JavaScript-powered redirect pages, often found on services like Google RSS feeds. This allows you to import the true target URL instead of the intermediate redirect page and also ensures your site is correctly identified as the referrer.
The Migrate Process JS Redirect Link module provides a Migrate process plugin to enable to enable you to request and extract a link from a inter-linked JS enabled redirect page commonly found on Google RSS feeds.
Background
e.g. Google will give a link like this on your rss feed:
https://news.google.com/rss/articles/CBMiVWh0dHBzOi8vd3d3LmxvbmRvbi1maXJ...
This page will typically contain a js redirect to:
https://www.london-fire.gov.uk/incidents/2023/january/maisonette-fire-st...
This module enables you to import the second link that comes without the inter-linked google page and cookie consent form etc. It also allows for imported links to show your site as a referrer rather than directing everything through Google.
Example 1
process:
title: title
'field_feed_item_description/format':
plugin: default_value
default_value: full_html
'field_feed_item_description/value': summary
'field_web_link/uri':
-
plugin: migrate_process_js_link
source: link
'field_web_link/title': titleExample 2 (with migrate_process_html)
process:
'body/value':
-
plugin: migrate_process_js_redirect_link
source: link
-
plugin: migrate_process_html
jsredirect: false // to be deprecated
-
plugin: dom
method: import
-
plugin: dom_select
selector: //meta[@property="og:image"]/@content
-
plugin: skip_on_empty
method: row
message: 'Field image is missing'
-
plugin: extract
index:
- 0
-
plugin: skip_on_condition
method: row
condition:
plugin: not:matches
regex: /^(https?:\/\/)[\w\d]/i
message: 'We only want a string if it starts with http(s)://[\w\d]'
-
plugin: file_remote_url
Ask your assistant about Migrate Process JS Redirect Link
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- migrate Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.