Skip to content

Commit

Permalink
Parse twitch feed URL for sign-up confirmation (#3774)
Browse files Browse the repository at this point in the history
  • Loading branch information
cychu42 authored Dec 8, 2022
1 parent ce522b3 commit 18ec299
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/web/app/src/components/SignUp/Forms/RSSFeeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ const RSSFeeds = connect<RSSFeedsFormProps, SignUpForm>(
setFieldValue(selected, selectedFeeds, true);
};

// Parse FeedUrl by Type to produce desired output for confirmation
const parseFeedUrlByType = ({ feedUrl, type }: DiscoveredFeed) => {
// For twitch URL on channel feed page, parse the feed url to find the twitch URL
if (type === 'twitch') {
const result = feedUrl.match(/https?:\/\/www.twitch.tv\/\w+/);
return result ? result[0] : feedUrl;
}
// By default, return the original feed url
return feedUrl;
};

useEffect(() => {
if (errors[input.name as keyof SignUpForm]) {
validateBlog();
Expand Down Expand Up @@ -288,7 +299,7 @@ const RSSFeeds = connect<RSSFeedsFormProps, SignUpForm>(
}
label={
<h1 className={classes.formControlLabel}>
{feed.type}: {feed.feedUrl}
{feed.type}: {parseFeedUrlByType(feed)}
</h1>
}
/>
Expand Down

0 comments on commit 18ec299

Please sign in to comment.