Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Let's say I have an original URL www.google.com
.
Using an input filter, we'll get one of: http://www.tinyurl.com/1c2
OR www.tinyurl.com/1c2
The problem with the second one, is that my domain name is prepended to the href, which would work out to http://www.mydomain.com/www.tinyurl.com/1c2
My ideal situation would be to have http://www.tinyurl.com/1c2
as the href for the link, but the text for the link show up as tinyurl.com/1c2
(that's minus the http and the www)
hook_shorten_create
doesn't help here as the URL returned will apply to both the href and the link text.
Thanks,
Mike
Comments
Comment #1
IceCreamYou CreditAttribution: IceCreamYou commentedHmm. I hadn't thought about that. The whole input filter thing was kind of an afterthought.
The most straightforward way to solve this is to just prepend "http://" to the $href in _shortener_url_behavior() in shortener.module if the $href doesn't already start with "http". I suppose that could get us into trouble though if there was a local shortening service that only returned relative URLs. So this will probably require adding an option to shorten_url() to specify whether the absolute URL is requested, and then _shortener_url_behavior() will have to manually strip the "http://" for the $caption.
Comment #2
Neslee Canil Pinto