Skip to content

Commit

Permalink
Changed URI escaping rule #187
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed May 28, 2013
1 parent 7d5412c commit 2e90be6
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions lib/plugins/processor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,12 @@ var getInfoFromFilename = function(str){
return result;
};

// Percent-encoding: http://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters
var escapeRule = {
' ': '-',
'!': '%21',
'#': '%23',
'$': '%24',
'&': '%26',
"'": '%27',
'(': '%28',
')': '%29',
'*': '%2A',
'+': '%2B',
',': '%2C',
'/': '%2F',
':': '%3A',
';': '%3B',
'=': '%3D',
'?': '%3F',
'@': '%40',
'[': '%5B',
']': '%5D'
};

// http://tools.ietf.org/html/rfc3986#section-2.2
// http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
var escape = function(str){
var str = str.toString().replace(/\s|!|#|\$|&|'|\(|\)|\*|\+|,|\/|:|;|\*|\?|@|\[|\]/g, function(match){
return escapeRule[match];
});
var str = str.toString()
.replace(/\s/g, '-')
.replace(/:|\/|\?|#|\[|\]|@|!|\$|&|'|\(|\)|\*|\+|,|;|=|\\|%|<|>|\./g, '');

if (filenameCaps == 1){
str = str.toLowerCase();
Expand Down

0 comments on commit 2e90be6

Please sign in to comment.