We use the ShareThis widget as a block. Country code is in the base path. So a typical blog post has the URL: http://www.example.com/in/blog/drupal-works
When we use a ShareThis service, it shares the URL: http://www.example.com/in//in/blog/drupal-works
This happens because the span
attribute st_url
has the wrong URL. I traced it down to sharethis/src/Plugin/Block/SharethisWidgetBlock.php code that builds the absolute URL:
$current_path = Url::fromRoute('')->toString(); $path = ($this->configuration['sharethis_path'] == 'global') ? '' : $current_path; global $base_url; $path_obj = Url::fromUri($base_url . '/' . $path, array( 'absolute' => TRUE, ) ); $mpath = $path_obj->toString();
If I replace $base_url
to get:
$path_obj = Url::fromUri('internal:/' . $path, array( 'absolute' => TRUE, ) );
it works fine for our site. However, I am not sure if using internal
is the correct code.
Apologies if this issue turns out to be a duplicate. I searched through the issue queue and found a couple of issues that affected SharethisManager.php, but not SharethisWidgetBlock.php.
Comment | File | Size | Author |
---|---|---|---|
#12 | diff_11-12.txt | 375 bytes | kostyashupenko |
#12 | 2910803-12.patch | 872 bytes | kostyashupenko |
#11 | sharethis_module_uses_the_wrong_url_to_share-2910803-11.patch | 877 bytes | Muath Khraisat |
#6 | sharethis_module_uses-2910803-6.patch | 630 bytes | purushotam.rai |
| |||
#5 | sharethis_module_uses-2910803-5.patch | 635 bytes | pratik_kamble |
|
Comments
Comment #2
abhijit.nadgouda CreditAttribution: abhijit.nadgouda commentedComment #3
abhijit.nadgouda CreditAttribution: abhijit.nadgouda commentedComment #4
abhijit.nadgouda CreditAttribution: abhijit.nadgouda commentedComment #5
pratik_kambleHi @abhijit.nadgouda,
I have tested your patch. It is generating wrong URL to share. If the current path is 'www.example.com/node/15' then it generating 'www.example.com/15'.
Extra slash is getting added to the URL. Added patch to fix the issue.
@purushotamrai please review the patch.
Comment #6
purushotam.rai CreditAttribution: purushotam.rai at QED42 commentedAgree with @pratik_kamble, we don't need an extra slash, rest works fine.
Comment #7
purushotam.rai CreditAttribution: purushotam.rai at QED42 commentedComment #9
purushotam.rai CreditAttribution: purushotam.rai at QED42 commentedPushed to 8.x-2.x
Thanks to all for your valuable inputs.
Thanks and Regards
Comment #11
Muath Khraisat CreditAttribution: Muath Khraisat at Vardot commentedI still have the problem. The following patch should resolve it.
Comment #12
kostyashupenkoReroll of #11 against 8.x-2.x