Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Fix grabbing urls from srcset attributes #224

Merged
merged 1 commit into from
Jun 10, 2018
Merged

Conversation

trotzig
Copy link
Contributor

@trotzig trotzig commented Jun 10, 2018

My first attempt at this (312ecd9) was too naive, it didn't take urls
with commas in them into account. In this second attempt, I've tried to
tdd things so that I know we can handle a wider range of values.

I've used https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
as a guide into figuring out possible values.

My first attempt at this (312ecd9) was too naive, it didn't take urls
with commas in them into account. In this second attempt, I've tried to
tdd things so that I know we can handle a wider range of values.

I've used https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img
as a guide into figuring out possible values.
@trotzig trotzig requested a review from lencioni June 10, 2018 16:02
Copy link

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

export default function getUrlsFromSrcset(value) {
const result = [];
let match;
while (match = SRCSET_ITEM.exec(value)) { // eslint-disable-line no-cond-assign
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'll make that change after I publish.

@trotzig trotzig merged commit d2d97d0 into master Jun 10, 2018
@trotzig trotzig deleted the fix-srcset-preload branch June 10, 2018 20:30
trotzig added a commit that referenced this pull request Jun 11, 2018
As pointed out by @ljharb in a previous PR: #224 (review)

Multiple benefits here:
- we avoid the while-loop
- no mutation of the lastIndex property of the regexp
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants