Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand regex to match attributes with single quotes #250

Merged
merged 7 commits into from
Jul 8, 2022
Merged
10 changes: 7 additions & 3 deletions src/Components/IssuesControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {TooltipIconButton} from './Buttons'
import {removeHashParams} from '../utils/location'
import {setCameraFromEncodedPosition, addCameraUrlParams, removeCameraUrlParams} from './CameraControl'
import {addHashParams} from '../utils/location'
import {isRunningLocally} from '../utils/network'


/** The prefix to use for issue id in the Url hash. */
Expand Down Expand Up @@ -136,8 +135,13 @@ export function Issues() {

if (issue.body.includes('img')) {
const isolateImageSrc = issue.body.split('src')[1].split('imageURL')[0]
const imageSrc = isolateImageSrc.match(/"([^"]*)"/)
imageUrl = isRunningLocally() ? imageUrl = isolateImageSrc : imageSrc[1]

// Match either single or double quote-wrapped attribute
// <img src = "..." /> OR <img src = '...' />
const imageSrc = isolateImageSrc.match(/"([^"]*)"|'([^']*)'/)

// Then filter out the non-matched capture group (as that value will be undefined)
imageUrl = imageSrc.slice(1).filter((u) => u !== undefined)[0]
} else {
imageUrl = ''
}
Expand Down