Fix hanlding trailing slash in asar package, close #2222
This commit is contained in:
parent
78e55414d4
commit
a2c26b8c74
2 changed files with 14 additions and 0 deletions
|
@ -54,6 +54,11 @@ bool GetChildNode(const base::DictionaryValue* root,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const base::DictionaryValue* dir,
|
const base::DictionaryValue* dir,
|
||||||
const base::DictionaryValue** out) {
|
const base::DictionaryValue** out) {
|
||||||
|
if (name == "") {
|
||||||
|
*out = root;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const base::DictionaryValue* files = NULL;
|
const base::DictionaryValue* files = NULL;
|
||||||
return GetFilesNode(root, dir, &files) &&
|
return GetFilesNode(root, dir, &files) &&
|
||||||
files->GetDictionaryWithoutPathExpansion(name, out);
|
files->GetDictionaryWithoutPathExpansion(name, out);
|
||||||
|
|
|
@ -85,6 +85,11 @@ describe 'asar package', ->
|
||||||
done()
|
done()
|
||||||
|
|
||||||
describe 'fs.lstatSync', ->
|
describe 'fs.lstatSync', ->
|
||||||
|
it 'handles path with trailing slash correctly', ->
|
||||||
|
p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1'
|
||||||
|
fs.lstatSync p
|
||||||
|
fs.lstatSync p + '/'
|
||||||
|
|
||||||
it 'returns information of root', ->
|
it 'returns information of root', ->
|
||||||
p = path.join fixtures, 'asar', 'a.asar'
|
p = path.join fixtures, 'asar', 'a.asar'
|
||||||
stats = fs.lstatSync p
|
stats = fs.lstatSync p
|
||||||
|
@ -136,6 +141,10 @@ describe 'asar package', ->
|
||||||
assert.throws throws, /ENOENT/
|
assert.throws throws, /ENOENT/
|
||||||
|
|
||||||
describe 'fs.lstat', ->
|
describe 'fs.lstat', ->
|
||||||
|
it 'handles path with trailing slash correctly', (done) ->
|
||||||
|
p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1'
|
||||||
|
fs.lstat p + '/', done
|
||||||
|
|
||||||
it 'returns information of root', (done) ->
|
it 'returns information of root', (done) ->
|
||||||
p = path.join fixtures, 'asar', 'a.asar'
|
p = path.join fixtures, 'asar', 'a.asar'
|
||||||
stats = fs.lstat p, (err, stats) ->
|
stats = fs.lstat p, (err, stats) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue