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

Separated trimLine content and url regexp's and made them work better #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/utils/trimLine.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

var urlOrContentRe = /(["'].+["'])|( +|:)url\(.+\)/
var contentRe = /(content:\s*["'])(?:.+)(["'])/
Copy link
Author

Choose a reason for hiding this comment

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

This regexp creates 2 match groups. The first is the content: " part and the second basically just amounts to the closing quotation mark and possibly semicolon.

var urlRe = /([\S ]+\:\s*url\s*\(["'])(?:.+)(["']\))/
Copy link
Author

Choose a reason for hiding this comment

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

This regexp matches anything before and after a url expression such as background: url("../images/someimage.png") center center; With that expression it would match background: url(" and ") center center;


/**
* @description separate out line comments
Expand All @@ -17,7 +18,7 @@ var trimLine = function( line ) {
this.cache.comment = ''

// remove urls, content strings
var noUrl = line.replace( urlOrContentRe, ' ' )
var noUrl = line.replace( contentRe, '$1$2' ).replace( urlRe, '$1$2' )

// strip line comments, if any exist after stripping urls
if ( noUrl.indexOf( '//' ) !== -1 ) {
Expand Down