Skip to content

Commit

Permalink
Fix Twitter sharing with empty hashtag parameter on IOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Beauvais committed May 31, 2019
1 parent 5933440 commit c289e19
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<a name="2.4.5"></a>
# [2.4.5](https://github.com/nicolasbeauvais/vue-social-sharing/compare/2.4.4...2.4.5) (2019-05-31)
- Fix IOS Twitter sharing with empty hashtags

<a name="2.4.4"></a>
# [2.4.4](https://github.com/nicolasbeauvais/vue-social-sharing/compare/2.4.3...2.4.4) (2019-05-29)
- Update Whatsapp share url to use API
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-social-sharing",
"version": "2.4.4",
"version": "2.4.5",
"homepage": "https://github.com/nicolasbeauvais/vue-social-sharing",
"authors": [
"nicolasbeauvais <nicolasbeauvais1@gmail.com>"
Expand Down
20 changes: 17 additions & 3 deletions dist/vue-social-sharing.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-social-sharing v2.4.4
* vue-social-sharing v2.4.5
* (c) 2019 nicolasbeauvais
* Released under the MIT License.
*/
Expand Down Expand Up @@ -234,11 +234,25 @@ var SocialSharing = {
createSharingUrl: function createSharingUrl (network) {
var ua = navigator.userAgent.toLowerCase();

/**
* On IOS, SMS sharing link need a special formating
* Source: https://weblog.west-wind.com/posts/2013/Oct/09/Prefilling-an-SMS-on-Mobile-Devices-with-the-sms-Uri-Scheme#Body-only
*/
if (network === 'sms' && (ua.indexOf('iphone') > -1 || ua.indexOf('ipad') > -1)) {
network += '_ios';
}

return this.baseNetworks[network].sharer
var url = this.baseNetworks[network].sharer;

/**
* On IOS, Twitter sharing shouldn't include a hashtag parameter if the hashtag value is empty
* Source: https://github.com/nicolasbeauvais/vue-social-sharing/issues/143
*/
if (network === 'twitter' && this.hashtags.length === 0) {
url.replace('&hashtags=@hashtags', '');
}

return url
.replace(/@url/g, encodeURIComponent(this.url))
.replace(/@title/g, encodeURIComponent(this.title))
.replace(/@description/g, encodeURIComponent(this.description))
Expand Down Expand Up @@ -375,7 +389,7 @@ var SocialSharing = {
}
};

SocialSharing.version = '2.4.4';
SocialSharing.version = '2.4.5';

SocialSharing.install = function (Vue) {
Vue.component('social-sharing', SocialSharing);
Expand Down
20 changes: 17 additions & 3 deletions dist/vue-social-sharing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-social-sharing v2.4.4
* vue-social-sharing v2.4.5
* (c) 2019 nicolasbeauvais
* Released under the MIT License.
*/
Expand Down Expand Up @@ -236,11 +236,25 @@ var SocialSharing = {
createSharingUrl: function createSharingUrl (network) {
var ua = navigator.userAgent.toLowerCase();

/**
* On IOS, SMS sharing link need a special formating
* Source: https://weblog.west-wind.com/posts/2013/Oct/09/Prefilling-an-SMS-on-Mobile-Devices-with-the-sms-Uri-Scheme#Body-only
*/
if (network === 'sms' && (ua.indexOf('iphone') > -1 || ua.indexOf('ipad') > -1)) {
network += '_ios';
}

return this.baseNetworks[network].sharer
var url = this.baseNetworks[network].sharer;

/**
* On IOS, Twitter sharing shouldn't include a hashtag parameter if the hashtag value is empty
* Source: https://github.com/nicolasbeauvais/vue-social-sharing/issues/143
*/
if (network === 'twitter' && this.hashtags.length === 0) {
url.replace('&hashtags=@hashtags', '');
}

return url
.replace(/@url/g, encodeURIComponent(this.url))
.replace(/@title/g, encodeURIComponent(this.title))
.replace(/@description/g, encodeURIComponent(this.description))
Expand Down Expand Up @@ -377,7 +391,7 @@ var SocialSharing = {
}
};

SocialSharing.version = '2.4.4';
SocialSharing.version = '2.4.5';

SocialSharing.install = function (Vue) {
Vue.component('social-sharing', SocialSharing);
Expand Down
4 changes: 2 additions & 2 deletions dist/vue-social-sharing.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-social-sharing",
"description": "A Vue.js component for sharing links to social networks",
"version": "2.4.4",
"version": "2.4.5",
"author": {
"name": "nicolasbeauvais",
"email": "nicolasbeauvais1@gmail.com"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SocialSharing from './social-sharing';

SocialSharing.version = '2.4.4';
SocialSharing.version = '2.4.5';

SocialSharing.install = (Vue) => {
Vue.component('social-sharing', SocialSharing);
Expand Down
16 changes: 15 additions & 1 deletion src/social-sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,25 @@ export default {
createSharingUrl (network) {
const ua = navigator.userAgent.toLowerCase();

/**
* On IOS, SMS sharing link need a special formating
* Source: https://weblog.west-wind.com/posts/2013/Oct/09/Prefilling-an-SMS-on-Mobile-Devices-with-the-sms-Uri-Scheme#Body-only
*/
if (network === 'sms' && (ua.indexOf('iphone') > -1 || ua.indexOf('ipad') > -1)) {
network += '_ios';
}

return this.baseNetworks[network].sharer
const url = this.baseNetworks[network].sharer;

/**
* On IOS, Twitter sharing shouldn't include a hashtag parameter if the hashtag value is empty
* Source: https://github.com/nicolasbeauvais/vue-social-sharing/issues/143
*/
if (network === 'twitter' && this.hashtags.length === 0) {
url.replace('&hashtags=@hashtags', '');
}

return url
.replace(/@url/g, encodeURIComponent(this.url))
.replace(/@title/g, encodeURIComponent(this.title))
.replace(/@description/g, encodeURIComponent(this.description))
Expand Down

0 comments on commit c289e19

Please sign in to comment.