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.
For a recent client project we needed to output a link without the protocol, for display purposes.
Instead of "http://www.google.com" we would output "www.google.com." Attaching patch...
Comment | File | Size | Author |
---|---|---|---|
#11 | link-no_protocol_formatter_reroll-2216399-11.patch | 1.63 KB | nileema.jadhav |
| |||
#9 | link-no_protocol_formatter-2216399-9.patch | 1.69 KB | mibfire |
| |||
#5 | link-no_protocol_formatter-2216399-4.patch | 1.6 KB | omarlopesino |
#3 | link-no_protocol_formatter-2216399-3.patch | 1.68 KB | jemond |
#1 | link-no_protocol_formatter-2216399-1.patch | 1.83 KB | jemond |
Comments
Comment #1
jemond CreditAttribution: jemond commentedPatch attached.
Comment #2
jemond CreditAttribution: jemond commentedComment #3
jemond CreditAttribution: jemond commentedPaths fixed.
Comment #4
jcfiala CreditAttribution: jcfiala commentedHm. Although it does remove the http/https scheme, there's more than just those two schemes that are allowed via the link module - I'd want the formatter to handle any scheme that comes up, either with a regex based on the allowed list, or using parse_url to strip them out.
Comment #5
omarlopesinoI add a patch using parse_url. I thinked about do finding the position of the '://' string, but i thinked that it would be possible that the url contains string in other parts.
Comment #6
omarlopesinoComment #8
mibfire CreditAttribution: mibfire commented@mistermoper
There is a error in link-no_protocol_formatter-2216399-4.patch patch.
This line:
has to be the following:
Comment #9
mibfire CreditAttribution: mibfire commentedAnd the first occurrence has to be replaced. I fixed both in a patch.
Comment #10
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedI needed this functionality as well.
Comment #11
nileema.jadhav CreditAttribution: nileema.jadhav as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedRe-rolled the patch #9
Comment #12
ruchirashree CreditAttribution: ruchirashree commentedReviewed and tested with D7.x, PHP 5.6, Mysql 5.5. Working as expected.
Comment #13
albertski CreditAttribution: albertski at Xeno Media, Inc. commented@ruchirashree Can you please change the status to Reviewed & tested by the community so the maintainer knows it is ready.
Comment #14
ruchirashree CreditAttribution: ruchirashree commentedChanging the status to RTBC.
Comment #16
nileema.jadhav CreditAttribution: nileema.jadhav as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedComment #17
nileema.jadhav CreditAttribution: nileema.jadhav as a volunteer and at TATA Consultancy Services for Pfizer, Inc. commentedAdded into 7.x-1.x-dev version.