Skip to content

Commit

Permalink
Merge 933854a into 34e9ea3
Browse files Browse the repository at this point in the history
  • Loading branch information
lsycxyj committed Jul 26, 2018
2 parents 34e9ea3 + 933854a commit 96d3b7e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
13 changes: 11 additions & 2 deletions index.js
Expand Up @@ -34,10 +34,18 @@ function urldata(value){
while(value[start] === " "){ start++; }
}


end = value.indexOf(")", start);
if (!openQuote) {
end = value.indexOf(")", start);
} else {
end = start;
while(value[end] !== openQuote && end < value.length) { end++; }
while(value[end] !== ")" && end < value.length){ end++; }
}

if(end < 0){
return result;
} else if (end === value.length) {
return result;
}
end--;
while(value[end]===" "){
Expand All @@ -55,4 +63,5 @@ function urldata(value){
}
return result;
}

module.exports = urldata;
10 changes: 5 additions & 5 deletions package.json
@@ -1,12 +1,12 @@
{
"name": "urldata",
"version": "0.0.1",
"version": "0.0.2",
"description": "Library to extract url data from css property",
"main": "index.js",
"repository": "lexich/urldata",
"scripts": {
"test": "istanbul test _mocha --report html -- test/*.js --reporter spec",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
"test": "istanbul test node_modules/mocha/bin/_mocha --report html -- test/*.js --reporter spec",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly --report html -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"keywords": [
"node",
Expand All @@ -18,9 +18,9 @@
"url": "https://github.com/lexich"
},
"license": "MIT",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"chai": "^4.1.2",
"coveralls": "^2.11.2",
"istanbul": "^0.3.2",
"mocha": "^2.0.0",
Expand Down
15 changes: 13 additions & 2 deletions test/main_spec.js
@@ -1,7 +1,9 @@
/*global describe, it*/
"use strict";
var urldata = require("../"),
should = require("should");
should = require("should"),
chai = require("chai"),
expect = chai.expect;

describe("urldata", function(){
it("check urldata simple url", function(){
Expand Down Expand Up @@ -40,11 +42,20 @@ describe("urldata", function(){
urldata("url(\"images/test.png\")")
);
});
it("check urldata with parentheses", function(){
["(images/test.png)"].should.eql(
urldata("url(\"(images/test.png)\")")
);
});
it("check urldata with wrong data", function(){
expect(urldata("")).to.be.undefined;
[].should.eql(
urldata("url")
);
["images/test.png\""].should.eql(
urldata("url(images/test.png\")")
);
["\' images/test.png"].should.eql(
[].should.eql(
urldata("url( \' images/test.png)")
);
});
Expand Down

0 comments on commit 96d3b7e

Please sign in to comment.