ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.21k stars 1k forks source link

bug: cannot run script from subdirectory starting with underscore #3466

Closed brodycj closed 4 years ago

brodycj commented 4 years ago

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 2.4.0
  @capacitor/core: 2.4.0
  @capacitor/android: 2.4.0
  @capacitor/electron: 2.4.0
  @capacitor/ios: 2.4.0

Installed Dependencies:

  @capacitor/cli 2.4.0
  @capacitor/android 2.4.0
  @capacitor/ios 2.4.0
  @capacitor/core 2.4.0
  @capacitor/electron not installed

[success] Android looking great! 👌
  Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌

Platform(s)

Android (behavior looks correct on iOS)

Current Behavior

With a script tag like this:

<script src="_underscore_subir/log2.js"></script>

I would encounter failures like these log messages:

D/Capacitor( 2418): Handling local request: http://localhost/_underscore_subir/log2.js
E/Capacitor( 2418): Unable to open asset URL: http://localhost/_underscore_subir/log2.js
E/Capacitor( 2418): Unable to open asset URL: http://localhost/_underscore_subir/log2.js
E/Capacitor( 2418): Unable to open asset URL: http://localhost/_underscore_subir/log2.js

Expected Behavior

It should be able to use script in a subdirectory starting with underscore (_).

Code Reproduction

https://github.com/brodybits/capacitor-subdir-test - reproduces with these assets in the www subdirectory tree:

www/index.html:

<head>
</head>
<body>
  <h1>subdirectory log test</h1>
  <script src="subdir1/log1.js"></script>
  <script src="_underscore_subir/log2.js"></script>
</body>

www/subdir1/log1.js:

console.log('log 1')

www/_underscore_subir/log2.js:

console.log('log 2')

Some log output on iOS

⚡️  Loading app at capacitor://localhost...
Reachable via WiFi
APP ACTIVE
⚡️  [log] - log 1
⚡️  [log] - log 2
⚡️  WebView loaded

Some log output on Android:

D/Capacitor( 2418): Handling local request: http://localhost/
D/EGL_emulation( 2418): eglMakeCurrent: 0xae948b80: ver 3 0
E/eglCodecCommon( 2418): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon( 2418): glUtilsParamSize: unknow param 0x000085b5
D/EGL_emulation( 2418): eglMakeCurrent: 0xae948b80: ver 3 0
D/Capacitor( 2418): Handling local request: http://localhost/subdir1/log1.js
D/Capacitor( 2418): Handling local request: http://localhost/_underscore_subir/log2.js
E/Capacitor( 2418): Unable to open asset URL: http://localhost/_underscore_subir/log2.js
E/Capacitor( 2418): Unable to open asset URL: http://localhost/_underscore_subir/log2.js
E/Capacitor( 2418): Unable to open asset URL: http://localhost/_underscore_subir/log2.js
E/eglCodecCommon( 2418): glUtilsParamSize: unknow param 0x000085b5
I/Capacitor/Console( 2418): File: http://localhost/subdir1/log1.js - Line 1 - Msg: log 1
D/Capacitor( 2418): Handling local request: http://localhost/favicon.ico

Other Technical Details

npm --version output: 6.14.7

node --version output: v12.18.3

Additional Context

This is one of the issues I encountered when trying out CapacitorJS with Snowpack and Vue: https://github.com/pikapkg/snowpack/discussions/905

Nothing super-critical, but I would love to see it resolved someday.

I did take a quick look at the code in android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java with the error message but have not seen a smoking gun so far.

jcesarmobile commented 4 years ago

see https://github.com/ionic-team/capacitor/issues/1750#issuecomment-511785165

ionitron-bot[bot] commented 2 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.