diff --git a/package-lock.json b/package-lock.json index cc2cc28..94969ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@phntms/react-share", - "version": "0.0.4", + "version": "0.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@phntms/react-share", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "dependencies": { "is-absolute-url": "^3.0.3" diff --git a/package.json b/package.json index 66e60f5..6c049eb 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@phntms/react-share", "description": "An all-in-one React library to implement custom Sharing Meta and Social Media Sharing Buttons.", - "version": "0.0.4", + "version": "0.0.5", "main": "lib/index.js", "types": "lib/index.d.ts", "homepage": "https://github.com/phantomstudios/react-share#readme", diff --git a/src/utils/getFacebookUrl.ts b/src/utils/getFacebookUrl.ts index ebe92c7..e23a7f7 100644 --- a/src/utils/getFacebookUrl.ts +++ b/src/utils/getFacebookUrl.ts @@ -9,11 +9,18 @@ export interface FacebookProps extends BaseShareProps { hashtag?: string; } -export const getFacebookUrl = ({ url, quote, hashtag }: FacebookProps) => - `https://www.facebook.com/sharer/sharer.php${objectToUrlParams({ +export const getFacebookUrl = ({ + url, + quote, + hashtag: suppliedHashtag, +}: FacebookProps) => { + let hashtag = suppliedHashtag; + if (hashtag && hashtag.charAt(0) !== "#") hashtag = `#${hashtag}`; + return `https://www.facebook.com/sharer/sharer.php${objectToUrlParams({ u: url, quote, - hashtag: hashtag?.charAt(0) === "#" ? hashtag : `#${hashtag}`, + hashtag, })}`; +}; export default getFacebookUrl;