Skip to content

Commit

Permalink
changed regex
Browse files Browse the repository at this point in the history
  • Loading branch information
gouravmpk committed Dec 7, 2023
1 parent e5d09bf commit d9a5c65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions frontend/app/src/bounties/BountyDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ const CodingLabels = styled.div<codingLangProps>`
const BountyDescription = (props: BountiesDescriptionProps) => {
const color = colors['light'];
const [dataValue, setDataValue] = useState([]);
// const [replitLink, setReplitLink] = useState('');
const [replitLink, setReplitLink] = useState('');
const [descriptionImage, setDescriptionImage] = useState('');

useEffect(() => {
if (props.description) {
const found = props?.description.match(/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/);
// setReplitLink(
// props?.description.match(
// /https?:\/\/(www\.)?[replit]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
// )
// );
const found = props?.description.match(/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))(?![^`]*`)/);
setReplitLink(
props?.description.match(
/https?:\/\/(?:www\.)?(?:replit\.[a-zA-Z0-9()]{1,256}|replit\.it)\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
)
);
setDescriptionImage(found && found.length > 0 && found[0]);
}
}, [props]);
Expand Down Expand Up @@ -166,7 +166,7 @@ const BountyDescription = (props: BountiesDescriptionProps) => {
{props.title?.length > 80 ? '...' : ''}
</EuiText>
</div>
{/* {descriptionImage && ( commented out reason-> #1059
{descriptionImage && (
<div className="DescriptionImage">
<img
src={descriptionImage}
Expand All @@ -176,10 +176,10 @@ const BountyDescription = (props: BountiesDescriptionProps) => {
width={'100%'}
/>
</div>
)} */}
)}
</Description>
<LanguageContainer>
{/* {replitLink && ( commented out reason-> #1059
{replitLink && (
<div onClick={() => window.open(replitLink[0])} style={{ display: 'flex' }}>
<CodingLabels
key={0}
Expand All @@ -198,7 +198,7 @@ const BountyDescription = (props: BountiesDescriptionProps) => {
<EuiText className="LanguageText">Replit</EuiText>
</CodingLabels>
</div>
)} */}
)}
{dataValue &&
dataValue?.length > 0 &&
dataValue?.map((lang: any, index: number) => (
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/bounties/BountyModalButtonSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ButtonSet = ({ showGithubBtn, ...props }: any) => {
</div>
</ButtonContainer>
)}
{/* {props?.replitLink && ( commented out reason-> #1059
{props?.replitLink && (
<ButtonContainer
topMargin={'16px'}
onClick={() => {
Expand Down Expand Up @@ -76,7 +76,7 @@ const ButtonSet = ({ showGithubBtn, ...props }: any) => {
/>
</div>
</ButtonContainer>
)} */}
)}
{props.tribe && (
<ButtonContainer
topMargin={'16px'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function WantedSummary(props: WantedSummaryProps) {
if (description) {
setReplitLink(
description.match(
/https?:\/\/(www\.)?[replit]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
/https?:\/\/(?:www\.)?(?:replit\.[a-zA-Z0-9()]{1,256}|replit\.it)\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/
)
);
}
Expand Down

0 comments on commit d9a5c65

Please sign in to comment.