shellscape/postcss-values-parser

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

Closed this issue · 3 comments

  • 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.

Hah this one made me smile. Good catch.

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.

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