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

Protocol-relative URL parsed as comment in url() function #65

Closed
jwilsson opened this Issue Feb 7, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@jwilsson
Copy link
Collaborator

jwilsson commented Feb 7, 2019

  • Webpack Version: N/A
  • Operating System (or Browser): macOS 10.14.2
  • Node Version: 11.9.0
  • postcss-values-parser Version: 3.0.0-beta.3

How Do We Reproduce?

Run this code:

const { parse } = require('postcss-values-parser');

const root = parse('url(//example.com)');

console.log(root.first.first);

Expected Behavior

root.first.first to be a Word node or whichever is suitable (I don't have a strong opinion on it, it could be multiple nodes as well).

Actual Behavior

root.first.first is a Comment node.

@shellscape

This comment has been minimized.

Copy link
Owner

shellscape commented Feb 7, 2019

Hah this one made me smile. Good catch.

@shellscape shellscape changed the title Protocol-relative URL parsed as comment in url() call on 3.0.0-beta.3 Protocol-relative URL parsed as comment in url() function Feb 7, 2019

@shellscape

This comment has been minimized.

Copy link
Owner

shellscape commented Feb 7, 2019

Fix for this is probably going to involve a few logical checks:

  • if parent node (this.current at that point) is Func and name === 'url
  • if parent node or prior sibling node does not have \n in raws

There are probably more but I haven't thought of them just yet.

shellscape added a commit that referenced this issue Feb 10, 2019

@shellscape

This comment has been minimized.

Copy link
Owner

shellscape commented Feb 10, 2019

Fixed in 3bb648a. Also added the isUrl property to Word for convenience. Will update the docs and publish shortly.

@shellscape shellscape closed this Feb 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment