Comparing version 0.1.0 to 0.1.1
@@ -74,3 +74,12 @@ 'use strict'; | ||
} | ||
result += sql.substr(idx, closeIdx - idx + 1).replace(regLB, '\\n'); | ||
addSpace(); | ||
var sub = sql.substr(idx, closeIdx - idx + 1); | ||
if (sub.indexOf(EOL) > 0) { | ||
var prev = idx ? sql[idx - 1] : ''; | ||
if (prev !== 'E' && prev !== 'e') { | ||
result += 'E'; | ||
} | ||
sub = sub.replace(regLB, '\\n'); | ||
} | ||
result += sub; | ||
idx = closeIdx; | ||
@@ -80,2 +89,11 @@ continue; | ||
addSpace(); | ||
result += s; | ||
} while (++idx < len); | ||
return result; | ||
function addSpace() { | ||
if (space) { | ||
@@ -87,9 +105,4 @@ if (result.length) { | ||
} | ||
} | ||
result += s; | ||
} while (++idx < len); | ||
return result; | ||
function throwError(code, error) { | ||
@@ -96,0 +109,0 @@ var position = getIndexPos(sql, idx, EOL); |
{ | ||
"name": "pg-minify", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Minifies PostgreSQL scripts.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -65,4 +65,17 @@ 'use strict'; | ||
describe("multi-line text", function () { | ||
it("must be returned empty", function () { | ||
expect(minify("'" + LB + "'")).toBe("E'\\n'"); | ||
expect(minify("'" + LB + LB + "'")).toBe("E'\\n\\n'"); | ||
expect(minify("text '" + LB + "'")).toBe("text E'\\n'"); | ||
expect(minify("text e'" + LB + "'")).toBe("text e'\\n'"); | ||
expect(minify("e'" + LB + "'")).toBe("e'\\n'"); | ||
expect(minify("E'" + LB + "'")).toBe("E'\\n'"); | ||
}); | ||
}); | ||
describe("quotes in strings", function () { | ||
it("must be ignored", function () { | ||
expect(minify("text''")).toBe("text''"); | ||
expect(minify("text ''")).toBe("text ''"); | ||
expect(minify("''''")).toBe("''''"); | ||
@@ -69,0 +82,0 @@ expect(minify("''''''")).toBe("''''''"); |
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
16252
379