Comparing version 0.1.1 to 0.1.2
@@ -23,3 +23,2 @@ 'use strict'; | ||
EOL = getEOL(sql), // End-Of-Line | ||
regLB = new RegExp(EOL, 'g'), | ||
space = false; | ||
@@ -76,4 +75,4 @@ | ||
addSpace(); | ||
var sub = sql.substr(idx, closeIdx - idx + 1); | ||
if (sub.indexOf(EOL) > 0) { | ||
var text = sql.substr(idx, closeIdx - idx + 1); | ||
if (text.indexOf(EOL) > 0) { | ||
var prev = idx ? sql[idx - 1] : ''; | ||
@@ -83,5 +82,7 @@ if (prev !== 'E' && prev !== 'e') { | ||
} | ||
sub = sub.replace(regLB, '\\n'); | ||
text = text.split(EOL).map(function (m) { | ||
return m.replace(/^\s+|\s+$/g, ''); | ||
}).join('\\n'); | ||
} | ||
result += sub; | ||
result += text; | ||
idx = closeIdx; | ||
@@ -92,3 +93,2 @@ continue; | ||
addSpace(); | ||
result += s; | ||
@@ -95,0 +95,0 @@ |
{ | ||
"name": "pg-minify", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Minifies PostgreSQL scripts.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -66,3 +66,3 @@ 'use strict'; | ||
describe("multi-line text", function () { | ||
it("must be returned empty", function () { | ||
it("must be returned with E", function () { | ||
expect(minify("'" + LB + "'")).toBe("E'\\n'"); | ||
@@ -75,2 +75,8 @@ expect(minify("'" + LB + LB + "'")).toBe("E'\\n\\n'"); | ||
}); | ||
it("must truncate text correctly", function () { | ||
expect(minify("' first " + LB + " last '")).toBe("E' first\\nlast '"); | ||
expect(minify("' first " + LB + " second " + LB + " third '")).toBe("E' first\\nsecond\\nthird '"); | ||
expect(minify("'\t first " + LB + "\t second \t" + LB + "\t third \t'")).toBe("E'\t first\\nsecond\\nthird \t'"); | ||
}); | ||
}); | ||
@@ -77,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16711
385