mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1178609 - fix join in add-on SDK loader to work with resource:/// (uplifted from addon-sdk) r=zer0
This commit is contained in:
parent
404415fbee
commit
6b5cd4f293
@ -194,14 +194,16 @@ function readURI(uri) {
|
||||
|
||||
// Combines all arguments into a resolved, normalized path
|
||||
function join (...paths) {
|
||||
let resolved = normalize(pathJoin(...paths))
|
||||
// OS.File `normalize` strips out the second slash in
|
||||
// `resource://` or `chrome://`, and third slash in
|
||||
// `file:///`, so we work around this
|
||||
resolved = resolved.replace(/^resource\:\/([^\/])/, 'resource://$1');
|
||||
resolved = resolved.replace(/^file\:\/([^\/])/, 'file:///$1');
|
||||
resolved = resolved.replace(/^chrome\:\/([^\/])/, 'chrome://$1');
|
||||
return resolved;
|
||||
let joined = pathJoin(...paths);
|
||||
let resolved = normalize(joined);
|
||||
|
||||
// OS.File `normalize` strips out any additional slashes breaking URIs like
|
||||
// `resource://`, `resource:///`, `chrome://` or `file:///`, so we work
|
||||
// around this putting back the slashes originally given, for such schemes.
|
||||
let re = /^(resource|file|chrome)(\:\/{1,3})([^\/])/;
|
||||
let matches = joined.match(re);
|
||||
|
||||
return resolved.replace(re, (...args) => args[1] + matches[2] + args[3]);
|
||||
}
|
||||
Loader.join = join;
|
||||
|
||||
|
@ -57,6 +57,10 @@ exports['test join'] = function (assert) {
|
||||
'resource://my/path/yeah/whoa');
|
||||
assert.equal(join('resource://my/path/yeah/yuh', './whoa'),
|
||||
'resource://my/path/yeah/yuh/whoa');
|
||||
assert.equal(join('resource:///my/path/yeah/yuh', '../whoa'),
|
||||
'resource:///my/path/yeah/whoa');
|
||||
assert.equal(join('resource:///my/path/yeah/yuh', './whoa'),
|
||||
'resource:///my/path/yeah/yuh/whoa');
|
||||
assert.equal(join('file:///my/path/yeah/yuh', '../whoa'),
|
||||
'file:///my/path/yeah/whoa');
|
||||
assert.equal(join('file:///my/path/yeah/yuh', './whoa'),
|
||||
|
Loading…
Reference in New Issue
Block a user