Skip to content

Commit

Permalink
Merge 2d74d01 into 5629183
Browse files Browse the repository at this point in the history
  • Loading branch information
GeyseR committed Oct 15, 2015
2 parents 5629183 + 2d74d01 commit 8e5ae13
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 287 deletions.
2 changes: 1 addition & 1 deletion dist/package/lib/css-url-versioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ CssUrlVersioner.prototype.getTheLastPart = function(quote, numeral, singleQuote,

CssUrlVersioner.prototype.insertVersion = function() {
var arrayUrl, dot, doubleQuotes, extension, i, len, newRegEx, newString, numeral, patternExt, patternQuotes, patternRightBracket, patternSimbols, patternUrl, quote, singleQuote, theLastPartOfTheRegExp, url;
patternUrl = /url([\(]{1})([\"|\']?)([a-zA-Z0-9\@\.\/_-]+)([\#]?[a-zA-Z0-9_-]+)?([\"|\']?)([\)]{1})/g;
patternUrl = /url([\(]{1})([\"|\']?)([a-zA-Z0-9\@\.\/\s_-]+)([\#]?[a-zA-Z0-9_-]+)?([\"|\']?)([\)]{1})/g;
patternQuotes = /(\"|\')/g;
patternExt = /(\.{1}[a-zA-Z0-9]{2,4})(\"|\')?/g;
patternSimbols = /([\#]{1})/g;
Expand Down
12 changes: 6 additions & 6 deletions dist/package/lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ Execute.prototype.readFile = function() {
};

Execute.prototype.validateFlag = function(flag) {
var e;
var e, error;
if (flag) {
try {
this.output = fs.readFileSync(this.pathOutput, {
encoding: 'utf8'
}).toString().replace(/\n/gi, '');
return true;
} catch (_error) {
e = _error;
} catch (error) {
e = error;
}
} else {
return false;
}
};

Execute.prototype.reset = function() {
var e;
var e, error;
try {
rimraf(this.pathDone, function() {});
rimraf(this.pathOutput, function() {});
} catch (_error) {
e = _error;
} catch (error) {
e = error;
console.log(e);
}
this.attempts = 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "css-url-versioner",
"version": "1.1.1",
"version": "1.1.2",
"description": "A node package for css url versioner",
"main": "dist/package/index",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion source/coffee/package/lib/css-url-versioner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ CssUrlVersioner::getTheLastPart = (quote, numeral, singleQuote, doubleQuotes, pa

CssUrlVersioner::insertVersion = () ->

patternUrl = /url([\(]{1})([\"|\']?)([a-zA-Z0-9\@\.\/_-]+)([\#]?[a-zA-Z0-9_-]+)?([\"|\']?)([\)]{1})/g
patternUrl = /url([\(]{1})([\"|\']?)([a-zA-Z0-9\@\.\/\s_-]+)([\#]?[a-zA-Z0-9_-]+)?([\"|\']?)([\)]{1})/g
patternQuotes = /(\"|\')/g
patternExt = /(\.{1}[a-zA-Z0-9]{2,4})(\"|\')?/g
patternSimbols = /([\#]{1})/g
Expand Down
204 changes: 38 additions & 166 deletions source/coffee/test/lib/css-url-versioner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -77,200 +77,72 @@ describe('cssUrl', () ->
)
return
)


assertVersioned = (arr, indx) ->
return () ->
instance = cssVersioner({
content: arr[indx]
})

it(arr[indx] + ' should be convert to: ' + arr[indx + 1] + '.', () ->
instance.output.should.be.equal(arr[indx + 1])
)

describe('Generated versions', () ->

queryString = '?v=' + version

withoutQuotes = ['url(sprite.png)', 'url(sprite.png' + queryString + ')',
'url(fonts/new.eot#ie)', 'url(fonts/new.eot' + queryString + '#ie)',
'url(img/abc.dfg.png)', 'url(img/abc.dfg.png' + queryString + ')',
'url(img/klm.nop.png#slug)', 'url(img/klm.nop.png' + queryString + '#slug)']
withoutQuotes = [
'url(sprite.png)', 'url(sprite.png' + queryString + ')',
'url(fonts/new.eot#ie)', 'url(fonts/new.eot' + queryString + '#ie)',
'url(img/abc.dfg.png)', 'url(img/abc.dfg.png' + queryString + ')',
'url(img/klm.nop.png#slug)', 'url(img/klm.nop.png' + queryString + '#slug)',
'url(file with space.woff)', 'url(file with space.woff' + queryString + ')'
]

describe('Without quotes:', () ->

describe(withoutQuotes[0], () ->

instance = cssVersioner({
content: withoutQuotes[0]
})

it(withoutQuotes[0] + ' should be convert to: ' + withoutQuotes[1] + '.', () ->
instance.output.should.be.equal(withoutQuotes[1])
return
)
return
)
for i in [0..withoutQuotes.length / 2 - 1]

describe(withoutQuotes[2], () ->

instance = cssVersioner({
content: withoutQuotes[2]
})

it(withoutQuotes[2] + ' should be convert to: ' + withoutQuotes[3] + '.', () ->
instance.output.should.be.equal(withoutQuotes[3])
return
)
return
)

describe(withoutQuotes[4], () ->

instance = cssVersioner({
content: withoutQuotes[4]
})

it(withoutQuotes[4] + ' should be convert to: ' + withoutQuotes[5] + '.', () ->
instance.output.should.be.equal(withoutQuotes[5])
return
)
return
)

describe(withoutQuotes[6], () ->

instance = cssVersioner({
content: withoutQuotes[6]
})

it(withoutQuotes[6] + ' should be convert to: ' + withoutQuotes[7] + '.', () ->
instance.output.should.be.equal(withoutQuotes[7])
return
)
return
)
describe(withoutQuotes[i * 2], assertVersioned(withoutQuotes, i * 2))

return
)

withSingleQuotes = ["url('sprite.png')", "url('sprite.png" + queryString + "')",
"url('fonts/new.eot#ie')", "url('fonts/new.eot" + queryString + "#ie')",
"url('img/abc.dfg.png')", "url('img/abc.dfg.png" + queryString + "')",
"url('img/klm.nop.png#slug')", "url('img/klm.nop.png" + queryString + "#slug')"]
withSingleQuotes = [
"url('sprite.png')", "url('sprite.png" + queryString + "')",
"url('fonts/new.eot#ie')", "url('fonts/new.eot" + queryString + "#ie')",
"url('img/abc.dfg.png')", "url('img/abc.dfg.png" + queryString + "')",
"url('img/klm.nop.png#slug')", "url('img/klm.nop.png" + queryString + "#slug')",
"url('file with space.woff')", "url('file with space.woff" + queryString + "')"
]

describe("With single quotes: '", () ->

describe(withSingleQuotes[0], () ->

instance = cssVersioner({
content: withSingleQuotes[0]
})

it(withSingleQuotes[0] + ' should be convert to: ' + withSingleQuotes[1] + '.', () ->
instance.output.should.be.equal(withSingleQuotes[1])
return
)
return
)

describe(withSingleQuotes[2], () ->

instance = cssVersioner({
content: withSingleQuotes[2]
})

it(withSingleQuotes[2] + ' should be convert to: ' + withSingleQuotes[3] + '.', () ->
instance.output.should.be.equal(withSingleQuotes[3])
return
)
return
)

describe(withSingleQuotes[4], () ->

instance = cssVersioner({
content: withSingleQuotes[4]
})

it(withSingleQuotes[4] + ' should be convert to: ' + withSingleQuotes[5] + '.', () ->
instance.output.should.be.equal(withSingleQuotes[5])
return
)
return
)
for i in [0..withSingleQuotes.length / 2 - 1]

describe(withSingleQuotes[6], () ->

instance = cssVersioner({
content: withSingleQuotes[6]
})

it(withSingleQuotes[6] + ' should be convert to: ' + withSingleQuotes[7] + '.', () ->
instance.output.should.be.equal(withSingleQuotes[7])
return
)
return
)
describe(withSingleQuotes[i * 2], assertVersioned(withSingleQuotes, i * 2))

return
)

withDoubleQuotes = ['url("sprite.png")', 'url("sprite.png' + queryString + '")',
'url("fonts/new.eot#ie")', 'url("fonts/new.eot' + queryString + '#ie")',
'url("img/abc.dfg.png")', 'url("img/abc.dfg.png' + queryString + '")',
'url("img/klm.nop.png#slug")', 'url("img/klm.nop.png' + queryString + '#slug")']


describe('With double quotes: "', () ->
withDoubleQuotes = [
'url("sprite.png")', 'url("sprite.png' + queryString + '")',
'url("fonts/new.eot#ie")', 'url("fonts/new.eot' + queryString + '#ie")',
'url("img/abc.dfg.png")', 'url("img/abc.dfg.png' + queryString + '")',
'url("img/klm.nop.png#slug")', 'url("img/klm.nop.png' + queryString + '#slug")',
'url("file with space.woff")', 'url("file with space.woff' + queryString + '")'
]

describe(withDoubleQuotes[0], () ->

instance = cssVersioner({
content: withDoubleQuotes[0]
})

it(withDoubleQuotes[0] + ' should be convert to: ' + withDoubleQuotes[1] + '.', () ->
instance.output.should.be.equal(withDoubleQuotes[1])
return
)
return
)

describe(withDoubleQuotes[2], () ->

instance = cssVersioner({
content: withDoubleQuotes[2]
})

it(withDoubleQuotes[2] + ' should be convert to: ' + withDoubleQuotes[3] + '.', () ->
instance.output.should.be.equal(withDoubleQuotes[3])
return
)
return
)

describe(withDoubleQuotes[4], () ->

instance = cssVersioner({
content: withDoubleQuotes[4]
})

it(withDoubleQuotes[4] + ' should be convert to: ' + withDoubleQuotes[5] + '.', () ->
instance.output.should.be.equal(withDoubleQuotes[5])
return
)
return
)

describe(withDoubleQuotes[6], () ->
describe('With double quotes: "', () ->

instance = cssVersioner({
content: withDoubleQuotes[6]
})
for i in [0..withDoubleQuotes.length / 2 - 1]

it(withDoubleQuotes[6] + ' should be convert to: ' + withDoubleQuotes[7] + '.', () ->
instance.output.should.be.equal(withDoubleQuotes[7])
return
)
return
)
describe(withDoubleQuotes[i * 2], assertVersioned(withDoubleQuotes, i * 2))

return
)


return
)

Expand Down
Loading

0 comments on commit 8e5ae13

Please sign in to comment.