Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Add pathPattern to allow wildcards in the URL #130

Open
sebaferreras opened this issue Nov 12, 2017 · 2 comments
Open

Add pathPattern to allow wildcards in the URL #130

sebaferreras opened this issue Nov 12, 2017 · 2 comments

Comments

@sebaferreras
Copy link

When working with subdomains of a given URL, the current implementation of this plugin only allows us to set the ANDROID_PATH_PREFIX which according to Android docs:

[...] specifies a partial path that is matched against only the initial part of the path in the Intent object.

In some cases, we need a more powerful way to define the URLs that are going to be handled by our app using wildcards. For example, if we want our app to handle URLs like www.domain.com/../subdomain/.* (where the two consecutive dots could match "en", "es", "fr", "de", ...) but we don't want our app to be opened with URLs like www.domain.com/../password-reset/.*

That can be achieved using pathPattern:

The pathPattern attribute specifies a complete path that is matched against the complete path in the Intent object, but it can contain the following wildcards:

  • An asterisk ('*') matches a sequence of 0 to many occurrences of the immediately preceding character.
  • A period followed by an asterisk (".*") matches any sequence of 0 to many characters.

In the meantime, we've added a custom hook that modifies the AndroidManifest.xml file and replaces the pathPrefix key by pathPattern and it works as expected. So maybe ANDROID_PATH_PATTERN could be added as another optional parameter of the plugin to handle this scenario.

Thanks :)

@mcastets
Copy link

mcastets commented Apr 23, 2019

That would be a great addition to this plugin. Could you share your custom hook?

EDIT: I'm going to use <edit-config> https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#edit-config

@webberig
Copy link

I've created a gist with a working solution:
https://gist.github.com/webberig/5778cce436c547d98cc4904e7d78d743

It uses a Cordova hook to modify AndroidManifest.xml and add pathPattern rules.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants