Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neutralino crashed each time if try to load a script outside of /assets #286

Closed
PhieF opened this issue May 24, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@PhieF
Copy link

PhieF commented May 24, 2020

Hi !

First, thanks for your work

Expected Behavior

<script src="/libs/jquery.min.js"></script>

should load javascript file ?

Actual Behavior
Neutralino crashed each time if try to load a script outside of /assets

<script src="/libs/jquery.min.js"></script>

will crash (core dumped)
but

<script src="/assets/jquery.min.js"></script>

seems to work

Specifications

  • NeutralinoJs Version: 1.4.0
  • NeutralinoJs CLI version: ?
  • Platform: Ubuntu 20.04
@blex41
Copy link

blex41 commented Jun 17, 2020

This is expected behavior, as you can see in Neutralino's router:

bool isAsset = path.find("/assets") != string::npos;
if(path == "/" + appname ){
return make_pair(settings::getFileContent("app\\index.html"), "text/html");
}
else if(path == "/neutralino.js"){
return make_pair(settings::getGlobalVars() + routes::getClientJs(), "text/javascript");
}
else if(path == "/settings.json"){
return make_pair(settings::getSettings().dump(), "application/json");
}
else if(isAsset && regex_match(path, regex(".*\\.(js|html|css)$"))) {
return getAsset(path);
}

Any request path that does not start with /assets and does not fulfill any other route typology will break. The documentation says to put any asset in that assets directory. But nothing prevents you from creating a libs folder inside of assets.

@shalithasuranga
Copy link
Member

Hey.. usually neutralino needs to see all of the app resources in assets. But regarding crashing. need to apply a fix. :) Thanks @blex41 for the reply.

@shalithasuranga shalithasuranga added the bug Something isn't working label Jan 21, 2021
@shalithasuranga shalithasuranga added this to the v1.8.0 milestone Jan 21, 2021
@shalithasuranga shalithasuranga modified the milestones: v1.8.0, v1.9.0 Feb 13, 2021
@shalithasuranga shalithasuranga removed this from the v1.9.0 milestone Mar 5, 2021
@shalithasuranga
Copy link
Member

Hey.. now the project structure is flexible and it's like any other static file server: https://neutralino.js.org/docs/developer-environment/project-structure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants