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

image-fetaure-view-point #35

Closed

Conversation

kartik-gupta-ij
Copy link
Member

#3

@kartik-gupta-ij kartik-gupta-ij self-assigned this Apr 22, 2023
@kartik-gupta-ij kartik-gupta-ij added the enhancement New feature or request label Apr 22, 2023
@kartik-gupta-ij
Copy link
Member Author

image

Comment on lines +13 to +18
const isImage =
data[key].indexOf(".jpg") > -1 ||
data[key].indexOf(".png") > -1 ||
(data[key].indexOf(".jpeg") > -1 &&
(data[key].indexOf("http") > -1 ||
data[key].indexOf("https") > -1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified:

Check for url with:

new URL(...)

Check for extension with regex:

function isImgUrl(url) {
  return /\.(jpg|jpeg|png)$/.test(url)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, we can avoid problem with url params by checking .pathname, not the whole URL

@kartik-gupta-ij kartik-gupta-ij deleted the image-view-data branch May 19, 2023 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants