Skip to content

Commit

Permalink
Fix hashtag sending through 'undefined' if empty (#20)
Browse files Browse the repository at this point in the history
* Fix hashtag sending through 'undefined' if empty

* Bump package version to 0.0.5
  • Loading branch information
PauloMFJ authored Nov 15, 2021
1 parent b8544d8 commit 7afd4f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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": "@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",
Expand Down
13 changes: 10 additions & 3 deletions src/utils/getFacebookUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 7afd4f9

Please sign in to comment.