capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

feat: send route path to route processor

Open gugu opened this issue 3 years ago • 3 comments

Feature Request

It would be great if RouteProcessor's process method in Android gets actual path instead of index.html

Description

If I have multiple index.html files and want to open /settings/index.html if URL is /settings/subpath/subpath, /other/index.html if URL is /other/subpath/subpath and /index.html in other cases. Previously I did this by monkey patching your module, but this time I noticed RouteProcessor class, which is created for custom routes. The problem is it sends path /index.html for every route without file extension and does not send actual path. Request path attribute in this process method will make it suitable for custom routing

Platform(s)

Android

Preferred Solution

call routeProcessor.process(basePath, path) instead of routeProcessor.process(basePath, '/index.html')

Alternatives

call routeProcessor.process(basePath, '/index.html', path) instead of routeProcessor.process(basePath, '/index.html')

Additional Context

gugu avatar Aug 05 '22 09:08 gugu

Can you provide more details about your use case? We only append index.html if the url to process is / or doesn't have a . on it (is not a file with extension). Since you say you are loading different index.html files, they have the ., so shouldn't load the default one. How are you loading those?

jcesarmobile avatar Feb 05 '24 15:02 jcesarmobile

Example: /settings/abc/def => /settings/index.html /everything/else => /index.html

gugu avatar Feb 05 '24 15:02 gugu

Yeah, I understood that from the issue description. I meant more details about what you are trying to accomplish with the route processor, are you using your own class? how are you navigating to those urls?

I think it should be possible to do at the moment, but would involve using your own BridgeWebViewClient subclass and RouteProcessor, but can be messy.

jcesarmobile avatar Feb 05 '24 18:02 jcesarmobile

Closing since there was no response.

Also I've verified that the route processor receives the whole path, the problem is that the default behavior of the "local server" is to append the index.html, so the feature looks like a duplicate of this one (allow loading from alternate paths) https://github.com/ionic-team/capacitor/issues/3912

jcesarmobile avatar Feb 29 '24 15:02 jcesarmobile

Yes, I guess it was an issue when I posted an issue, looks like everything is okay now

gugu avatar Feb 29 '24 15:02 gugu

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.

ionitron-bot[bot] avatar Mar 30 '24 15:03 ionitron-bot[bot]