PencilCode / pencilcode

An online IDE for kids: pencilcode.net.
http://dev.pencilcode.net/
MIT License
167 stars 100 forks source link

Don't return placeholder HTML for non-existing .js files #222

Open yanamal opened 8 years ago

yanamal commented 8 years ago

I'm playing around with loading third-party .js libraries (including ones that are only available when the page is viewed through a special browser), and the libraries, in turn, sometimes try to load other .js files where they assume an incorrect (local) path.

So I often end up asking for a url like yanamal.pencilcode.net/.../*.js which does not exist. But for all non-existent URLs, pencil code returns a placeholder HTML page:

<pre>
No file doggames/cordova.js found.

<a href="/doggames/">Up to /doggames/</a>
<a href="/edit/doggames/cordova.js" rel="nofollow">Create /home/doggames/cordova.js</a>
</pre>

So when the script tries to parse that as javascript, it gets very confused and throws: Uncaught SyntaxError: Unexpected token < which isn't very helpful.

I think it'd be better if, for requests that are .js or other clearly non-html extensions, it either gave a clearer 404 or maybe even returned a completely blank file (well, a blank would be best in my particular use case, anyway).