Closed
Bug 1178609
Opened 9 years ago
Closed 8 years ago
`join` in loader.js does not work with resource:///
Categories
(Add-on SDK Graveyard :: General, defect)
Add-on SDK Graveyard
General
Tracking
(firefox43 fixed)
RESOLVED
FIXED
mozilla43
Tracking | Status | |
---|---|---|
firefox43 | --- | fixed |
People
(Reporter: jlong, Assigned: jlong)
References
Details
Attachments
(1 file, 1 obsolete file)
I am creating a main module like this: let mainModule = loader.Module( "resource:///modules/devtools/debugger/", "resource:///modules/devtools/debugger/main.js" ); However, there is a bug inside loader that doesn't work with `resource` paths with a triple-slash. This is how you loader browser frontend files, so I need to do this. `join` already looks pretty busted. In the comments it says that the `normalize` function it uses takes out a slash, and we need to add it back in. It looks like in my case, it takes out *two* slashes. I have no idea what the elegant solution is. This made it work for me: function join (...paths) { let tripleResource = false; if(paths[0].indexOf('resource:///') === 0) { tripleResource = true; } 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\:\/([^\/])/, tripleResource ? 'resource:///$1' : 'resource://$1'); resolved = resolved.replace(/^file\:\/([^\/])/, 'file:///$1'); resolved = resolved.replace(/^chrome\:\/([^\/])/, 'chrome://$1'); return resolved; }
Comment 1•9 years ago
|
||
(In reply to James Long (:jlongster) from comment #0) > `join` already looks pretty busted. In the comments it says that the > `normalize` function it uses takes out a slash, and we need to add it back > in. It looks like in my case, it takes out *two* slashes. It takes two slashes also from file:///, already. Basically, it reduces to one slash, no matter what – and not sure why. > I have no idea what the elegant solution is. This made it work for me: We could probably do something like that: function join (...paths) { let joined = pathJoin(...paths); let resolved = normalize(joined); // OS.File `normalize` strips out the second slash in // `resource://` or `chrome://`, and third slash in // `file:///`, so we work around this let re = /^(resource|file|chrome)(\:\/{1,3})([^\/])/; let matches = joined.match(re); return resolved.replace(re, (...args) => args[1] + matches[2] + args[3]); } We basically put back the slashes originally given, for such schemes.
Assignee | ||
Comment 2•9 years ago
|
||
(In reply to Matteo Ferretti [:matteo] [:zer0] from comment #1) > We basically put back the slashes originally given, for such schemes. Sorry I didn't reply to this! The leak issue has been hugely distracting... Yeah, that approach sounds great!
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → jlong
Assignee | ||
Comment 3•9 years ago
|
||
This is exactly your code, but take a look anyway :p I know you'll probably want tests, but I still can't get any of the tests to run. My patches are really tiny though and it shouldn't be hard to write a quick test, but I'll need your help with that if that's ok?
Attachment #8630224 -
Flags: review?(zer0)
Comment 4•9 years ago
|
||
James, I took the code and add the unit test, let me if it's OK. I created a PR directly on github, to merge with SDK master repo.
Attachment #8630224 -
Attachment is obsolete: true
Attachment #8630224 -
Flags: review?(zer0)
Attachment #8632792 -
Flags: feedback?(jlong)
Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8632792 [details] [review] https://github.com/mozilla/addon-sdk/pull/2022 cool thanks!
Attachment #8632792 -
Flags: feedback?(jlong) → feedback+
Comment 6•8 years ago
|
||
Commits pushed to master at https://github.com/mozilla/addon-sdk https://github.com/mozilla/addon-sdk/commit/b669babc413f8e81895f37362ec1b37124cf6275 Bug 1178609 - `join` in loader.js does not work with resource:/// https://github.com/mozilla/addon-sdk/commit/d046f17c75a25e3a5f5296bab1bd7fce0533ac59 Merge pull request #2022 from ZER0/join/1178609 fix Bug 1178609 - `join` in loader.js does not work with resource:///
Updated•8 years ago
|
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 7•8 years ago
|
||
Leaving open until it lands on m-c, which I'll do soon
Assignee | ||
Updated•8 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 8•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=3250f4708ba9
https://hg.mozilla.org/mozilla-central/rev/b88ff909d103
Status: REOPENED → RESOLVED
Closed: 8 years ago → 8 years ago
status-firefox43:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in
before you can comment on or make changes to this bug.
Description
•