At seajs/src/util-path.js, double slash has not been replaced!
var DOT_RE = /\/\.\//g
var DOUBLE_DOT_RE = /\/[^/]+\/\.\.\//
function realpath(path){
path = path.replace(DOT_RE, '/')
while(path.match(DOUBLE_DOT_RE)) {
path = path.replace(DOUBLE_DOT_RE, '/')
}
console.log(path)
}
var fakepath = 'http://test.com/a//./b/../c'
realpath(fakepath) // 'http://test.com/a//c'
This function realpath does not replace double slash. I test with nodejs.
So, i add two line:
var DOT_RE = /\/\.\//g
var DOUBLE_DOT_RE = /\/[^/]+\/\.\.\//
// replace double slash
var DOUBLE_SLASH = /[^:]\/\//g
function realpath(path){
path = path.replace(DOT_RE, '/')
while(path.match(DOUBLE_DOT_RE)) {
path = path.replace(DOUBLE_DOT_RE, '/')
}
path = path.replace(DOUBLE_SLASH, '$1/');
console.log(path)
}
var fakepath = 'http://test.com/a//./b/../c'
realpath(fakepath) // 'http://test.com/a/c'
Is it correct?