Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Then "main" property of package.json doesn't accept complicated parameters #274

Closed
zhizhangchen opened this Issue · 9 comments

4 participants

@zhizhangchen

In the package.json of an application, if I configure the "main" property to something as simple as "index.html?url=test", my application can get that parameter correctly. But something like "index.html?url=file:///c:/canvas" or "index.html?url=filesysmte:file:///canvas" doesn't work.

@Mithgol

It's actually worse than not getting a parameter. The main property defined as index.html?url=file:///c:/canvas prevents your application from starting at all.

This field should contain a filename only, I presume; node-webkit does not expect a query string there, and thus the slashes are probably treated as directory names' separators (and the index.html?url=file: directory does not exist, so the main file is never found).

If you need to store some parameters in a JSON file, then you should probably store them is some other JSON file (not in package.json's main field) and read them by your application separately after it starts (for example, JSON.parse( require('fs').readFileSync('your.json', 'utf8') )).

You could also pass some parameters through the command line and read them with require('nw.gui').App.argv later.

@rogerwang
Owner

The OP just proposed to me that the property should be handled as a URL: file://path/to/package/main_property_string , if the string doesn't have any protocol prefix.

@Mithgol

In node-webkit version 0.7.0 the new App protocol was introduced.

That protocol allows "main": "app://whatever/index.html?url=file:///c:/canvas" in a manifest.

If a query string in app:// is correctly processed, this issue should be fixed.

(I haven't yet tested it personally though.)

@Mithgol

I've just tested.

The application is frozen on the “Starting...” stage now.

@Mithgol

That's probably a separate issue related to the processing of the new app://… protocol.

I've opened a new issue #990 to report it.

@tommoor
Collaborator

@Mithgol still an issue?

@Mithgol

@tommoor As far as I see, "main": "index.html?url=file:///c:/canvas" in package.json (as in an example above) still prevents node-webkit v0.8.6 from starting correctly. (It starts, but it does not load index.html.)

However, we should probably decide that the main property has never been intended to work this way — and close the issue. Probably mentioning in the wiki that ?parameters are not allowed when main contains a filename.

@Mithgol

And I've just mentioned it in the wiki.

@tommoor
Collaborator

Perfect :smile:

@tommoor tommoor closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.