[Pkg-javascript-commits] [node-entities] 35/63: compile: sort entities descending
Wolfgang Borgert
debacle at moszumanska.debian.org
Mon Sep 22 08:15:46 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to branch master
in repository node-entities.
commit 51d3750be056424c13e7ebf729bd3df03289d434
Author: fb55 <me at feedic.com>
Date: Sun Feb 16 21:07:34 2014 +0100
compile: sort entities descending
entities will now prefer longer entities. I’m not sure why I didn’t
experience this bug earlier.
---
compile.js | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/compile.js b/compile.js
index 910741b..d547fa1 100644
--- a/compile.js
+++ b/compile.js
@@ -23,9 +23,13 @@ modes.reduce(function(prev, name, i){
return obj;
}, null);
+function sortDesc(a, b){
+ return a < b ? 1 : -1;
+}
+
function getReplacer(obj){
- var keys = Object.keys(obj).sort();
- var re = keys.join("|").replace(/(\w+)\|\1;/g, "$1;?");
+ var keys = Object.keys(obj).sort(sortDesc);
+ var re = keys.join("|")//.replace(/(\w+);\|\1/g, "$1;?");
// also match hex and char codes
re += "|#[xX][\\da-fA-F]+;?|#\\d+;?";
@@ -34,7 +38,7 @@ function getReplacer(obj){
}
function getStrictReplacer(obj){
- var keys = Object.keys(obj).sort().filter(RegExp.prototype.test, /;$/);
+ var keys = Object.keys(obj).sort(sortDesc).filter(RegExp.prototype.test, /;$/);
var re = keys.map(function(name){
return name.slice(0, -1); //remove trailing semicolon
}).join("|");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-entities.git
More information about the Pkg-javascript-commits
mailing list