Skip to content

Commit

Permalink
Refactor createURL function in Footer component
Browse files Browse the repository at this point in the history
  • Loading branch information
Mim1991 committed Jan 12, 2024
1 parent 83d1d07 commit 6621d13
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,11 @@ export class Footer extends React.PureComponent<IFooterProps, IFooterState> {
});
}

createURL = (utmSource: string, utmCampaign: string) => {
const url = new URL("https://www.datacamp.com/");
const params = new URLSearchParams({
utm_source: utmSource,
utm_campaign: utmCampaign,
});
url.search = params.toString();
return url.toString();
};

public render() {
const datacampUrl = this.createURL(
this.props.utmSource,
this.props.utmCampaign
);

const { utmSource, utmCampaign } = this.props;
const baseUrl = "https://www.datacamp.com/";
const queryParams = `utm_source=${utmSource}&utm_campaign=${utmCampaign}`;
const datacampUrl = `${baseUrl}?${queryParams}`;
return (
<div className={styles.footer}>
{this.props.hint ? (
Expand Down

0 comments on commit 6621d13

Please sign in to comment.