mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-26 22:20:56 +00:00
Merge pull request #1540 from bitwiseman/uri
Fixed support for data URI with test
This commit is contained in:
commit
5aec460246
@ -373,7 +373,7 @@ Beautifier.prototype.beautify = function() {
|
||||
this.print_string(this._ch);
|
||||
this.eatWhitespace();
|
||||
this._ch = this._input.next();
|
||||
if (this._ch === ')' || this._ch === '"' || this._ch !== '\'') {
|
||||
if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
|
||||
this._input.back();
|
||||
parenLevel++;
|
||||
} else if (this._ch) {
|
||||
|
@ -370,6 +370,30 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea
|
||||
'\topacity: 0.9;\n' +
|
||||
'\tfilter: alpha(opacity=90);\n' +
|
||||
'}');
|
||||
|
||||
// simple data uri base64 test
|
||||
t(
|
||||
'a { background: url(data:image/gif;base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=); }',
|
||||
// -- output --
|
||||
'a {\n' +
|
||||
'\tbackground: url(data:image/gif;base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=);\n' +
|
||||
'}');
|
||||
|
||||
// non-base64 data
|
||||
t(
|
||||
'a { background: url(data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E); }',
|
||||
// -- output --
|
||||
'a {\n' +
|
||||
'\tbackground: url(data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E);\n' +
|
||||
'}');
|
||||
|
||||
// Beautifier does not fix or mitigate bad data uri
|
||||
t(
|
||||
'a { background: url(data: image/gif base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=); }',
|
||||
// -- output --
|
||||
'a {\n' +
|
||||
'\tbackground: url(data: image/gif base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=);\n' +
|
||||
'}');
|
||||
|
||||
|
||||
//============================================================
|
||||
|
@ -296,6 +296,30 @@ class CSSBeautifierTest(unittest.TestCase):
|
||||
'\topacity: 0.9;\n' +
|
||||
'\tfilter: alpha(opacity=90);\n' +
|
||||
'}')
|
||||
|
||||
# simple data uri base64 test
|
||||
t(
|
||||
'a { background: url(data:image/gif;base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=); }',
|
||||
# -- output --
|
||||
'a {\n' +
|
||||
'\tbackground: url(data:image/gif;base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=);\n' +
|
||||
'}')
|
||||
|
||||
# non-base64 data
|
||||
t(
|
||||
'a { background: url(data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E); }',
|
||||
# -- output --
|
||||
'a {\n' +
|
||||
'\tbackground: url(data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E);\n' +
|
||||
'}')
|
||||
|
||||
# Beautifier does not fix or mitigate bad data uri
|
||||
t(
|
||||
'a { background: url(data: image/gif base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=); }',
|
||||
# -- output --
|
||||
'a {\n' +
|
||||
'\tbackground: url(data: image/gif base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=);\n' +
|
||||
'}')
|
||||
|
||||
|
||||
#============================================================
|
||||
|
@ -165,6 +165,18 @@ exports.test_data = {
|
||||
tests: [{
|
||||
input: '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity = 90);\n}',
|
||||
output: '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity=90);\n}'
|
||||
}, {
|
||||
comment: 'simple data uri base64 test',
|
||||
input: 'a { background: url(data:image/gif;base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=); }',
|
||||
output: 'a {\n\tbackground: url(data:image/gif;base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=);\n}'
|
||||
}, {
|
||||
comment: 'non-base64 data',
|
||||
input: 'a { background: url(data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E); }',
|
||||
output: 'a {\n\tbackground: url(data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E);\n}'
|
||||
}, {
|
||||
comment: 'Beautifier does not fix or mitigate bad data uri',
|
||||
input: 'a { background: url(data: image/gif base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=); }',
|
||||
output: 'a {\n\tbackground: url(data: image/gif base64,R0lGODlhCwALAJEAAAAAAP///xUVFf///yH5BAEAAAMALAAAAAALAAsAAAIPnI+py+0/hJzz0IruwjsVADs=);\n}'
|
||||
}]
|
||||
}, {
|
||||
name: "Support simple language specific option inheritance/overriding",
|
||||
|
Loading…
Reference in New Issue
Block a user