first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
.web-one { background: url("http://www.google.com/images/srpr/logo3w.png"); }
.web-two { background: url(http://www.google.com/images/srpr/logo3w.png); }
.web-three { background: url('http://www.google.com/images/srpr/logo3w.png'); }
.absolute-one { background: url("/resources.png"); }
.absolute-two { background: url(/resources.png); }
.absolute-three { background: url('/resources.png'); }
+11
View File
@@ -0,0 +1,11 @@
.web-one { background: url("http://yandex.ru/images/srpr/logo3w.png"); }
.web-two { background: url(http://yandex.ru/images/srpr/logo3w.png); }
.web-three { background: url('http://yandex.ru/images/srpr/logo3w.png'); }
.absolute-one { background: url("http://mysite.com/resources.png"); }
.absolute-two { background: url(http://mysite.com/resources.png); }
.absolute-three { background: url('http://mysite.com/resources.png'); }
+9
View File
@@ -0,0 +1,9 @@
.png { background: url(local/resources.png); }
.gif { background: url("local/resources.gif"); }
.svg { background: url('local/resources.svg'); }
.jpg { background: url('local/resources.jpg'); }
.jpeg { background: url('local/resources.jpeg'); }
+9
View File
@@ -0,0 +1,9 @@
.png { background: url(global/resources.png); }
.gif { background: url("global/resources.gif"); }
.svg { background: url('global/resources.svg'); }
.jpg { background: url('global/resources.jpg'); }
.jpeg { background: url('global/resources.jpeg'); }
+3
View File
@@ -0,0 +1,3 @@
.blank {
background: url();
}
+3
View File
@@ -0,0 +1,3 @@
.blank {
background: url();
}
+3
View File
@@ -0,0 +1,3 @@
.datauri {
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzFlNTc5OSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzI5ODlkOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzIwN2NjYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3ZGI5ZTgiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
}
+3
View File
@@ -0,0 +1,3 @@
.datauri {
background: url(image.png);
}
+9
View File
@@ -0,0 +1,9 @@
.filter {
background-image: url('local/file');
content: url('local/file');
cue-after: url('local/file');
cue-before: url('local/file');
cursor: url('local/file'), url('local/file2');
list-style-image: url('local/file');
play-during: url('local/file');
}
+9
View File
@@ -0,0 +1,9 @@
.filter {
background-image: url('local/file');
content: url('global/file');
cue-after: url('local/file');
cue-before: url('local/file');
cursor: url('global/file'), url('global/file2');
list-style-image: url('local/file');
play-during: url('local/file');
}
+13
View File
@@ -0,0 +1,13 @@
@font-face {
font-family: 'PT Sans';
font-style: normal;
font-weight: normal;
src: local('PT Sans'), local('PTSans'), url('local/font.eot?#iefix&v=3.2.1') format('eot');
}
@font-face {
font-family: 'PT Sans';
font-style: normal;
font-weight: normal;
src: local('PT Sans'), local('PTSans'), url(local/font.woff) format('woff');
}
+13
View File
@@ -0,0 +1,13 @@
@font-face {
font-family: 'PT Sans';
font-style: normal;
font-weight: normal;
src: local('PT Sans'), local('PTSans'), url('global/font.eot?#iefix&v=3.2.1') format('eot');
}
@font-face {
font-family: 'PT Sans';
font-style: normal;
font-weight: normal;
src: local('PT Sans'), local('PTSans'), url(global/font.woff) format('woff');
}
+5
View File
@@ -0,0 +1,5 @@
@import "local/style.css";
.rule {
background: url( "local/image.png" );
}
+5
View File
@@ -0,0 +1,5 @@
@import "global/style.css";
.rule {
background: url( "local/image.png" );
}
+3
View File
@@ -0,0 +1,3 @@
.multiple {
background: url('local/one.jpg'), url('local/two.jpg'), url('local/three.jpg');
}
+3
View File
@@ -0,0 +1,3 @@
.multiple {
background: url('global/one.jpg'), url('global/two.jpg'), url('global/three.jpg');
}
+3
View File
@@ -0,0 +1,3 @@
.rule {
background: url( "local/image.png" );
}
@@ -0,0 +1,3 @@
.rule {
background: url( "global/image.png" );
}
+9
View File
@@ -0,0 +1,9 @@
.properties {
background-image: url('local/file');
content: url('local/file');
cue-after: url('local/file');
cue-before: url('local/file');
cursor: url('local/file'), url('local/file2');
list-style-image: url('local/file');
play-during: url('local/file');
}
+9
View File
@@ -0,0 +1,9 @@
.properties {
background-image: url('global/file');
content: url('global/file');
cue-after: url('global/file');
cue-before: url('global/file');
cursor: url('global/file'), url('global/file2');
list-style-image: url('global/file');
play-during: url('global/file');
}
+11
View File
@@ -0,0 +1,11 @@
.rule1 {
background: url( 'local/test' );
}
.rule2 {
background: url( 'global/test' );
}
.rule3 {
background: url( 'test' );
}
+11
View File
@@ -0,0 +1,11 @@
.rule1 {
background: url( 'local/test1' );
}
.rule2 {
background: url( 'global/test2' );
}
.rule3 {
background: url( 'test3' );
}
+142
View File
@@ -0,0 +1,142 @@
/*global describe, it */
"use strict";
var fs = require("fs");
var assert = require("assert");
var postcss = require("postcss");
var urlrewrite = require("../index.js");
var fixture = function (name) {
return fs.readFileSync("test/fixtures/" + name + ".css", "utf8").trim();
};
var compareFixtures = function (name, options) {
var actual = postcss(urlrewrite(options)).process(fixture(name)).css.trim();
var expected = fixture(name + ".out");
return assert.equal(actual, expected);
};
describe("postcss-urlrewrite", function () {
describe("paths in absolute rules", function () {
it("should be replaced", function () {
var config = {
rules: [
{ from: "http://www.google.com/", to: "http://yandex.ru/" },
{ from: /^\//, to: "http://mysite.com/" },
],
};
compareFixtures("absolute", config);
});
});
describe("different file types", function () {
it("should return must not affect replacement", function () {
var config = {
rules: [{ from: "local", to: "global" }],
};
compareFixtures("backgrounds", config);
});
});
describe("data-uris", function () {
it("should be replaceable", function () {
var config = {
rules: function (uri) {
uri.href("image.png");
},
};
compareFixtures("datauri", config);
});
});
describe('only "content" and "cursor" properties', function () {
it("should be updated", function () {
var config = {
properties: ["content", "cursor"],
rules: [{ from: "local", to: "global" }],
};
compareFixtures("filter", config);
});
});
describe("fonts src with ie hacks", function () {
it("should be replaced without errors", function () {
var config = {
rules: [{ from: "local", to: "global" }],
};
compareFixtures("fonts", config);
});
});
describe('only "content" and "cursor" properties', function () {
it("should be updated", function () {
var config = {
imports: true,
properties: false,
rules: [{ from: "local", to: "global" }],
};
compareFixtures("imports", config);
});
});
describe("multiple url() in property value", function () {
it("should be replaced without errors", function () {
var config = {
rules: [{ from: "local", to: "global" }],
};
compareFixtures("multiple", config);
});
});
describe("all properties from css 2.1 spec", function () {
it("should be replaceable", function () {
var config = {
rules: [{ from: "local", to: "global" }],
};
compareFixtures("properties", config);
});
});
describe("if multiple rules match value", function () {
it("only first should trigger replace", function () {
var config = {
rules: [
{ from: /local\/test/, to: "$&1" },
{ from: /global\/test/, to: "$&2" },
{ from: /test/, to: "$&3" },
],
};
compareFixtures("rules", config);
});
});
describe('if properties value is "true"', function () {
it("it should not return error", function () {
var config = {
properties: true,
rules: [{ from: "local", to: "global" }],
};
compareFixtures("properties-default", config);
});
});
describe("if blank url()", function () {
it("it should not return error", function () {
var config = {
rules: [{ from: "local", to: "global" }],
};
compareFixtures("blank-url", config);
});
});
});