4

I'm adding an intent filter to my android application and I want it to catch requests that go http://www.somedomain.com/[numericValue] . I only want to catch it if the path is numeric, but if it has text, I don't care about it.

I tried the pathPattern of [0123456789]*, but that didn't work. Is this possible to do?

2
  • Impractical, but you could try brute-forcing it with something like http://www.somedomain.com/0*1*0*2*0*3*0*4*0*5*0*6*0*7*0*8*0*9*1*1*2*1*3*1*4*1*5*1*6*1*7*1*8*1*9*2*2*3*2*4*2*5*2*6*2*7*2*8*2*9*3*3*4*3*5* and so on.
    – KTibow
    Commented Apr 27, 2020 at 1:55
  • @KTibow Unfortunately this does not seem to work. I tried that, but the found that a simple case as /0*1* only matches /1 og /01. It seems to be impossible. I just found a way - see my answer. Commented Mar 19, 2021 at 10:20

2 Answers 2

2

The pathPattern is not a full regex. Rather, it uses a "simple glob", where * means zero or more of the immediately preceding character -- in your case, zero or more ] characters.

Off the top of my head, I do not see how you can convert your desired pattern into something that can readily match a "simple glob".

0
0

I have tested KTibow sample but that does not work.

But a way to hack it is that it is possible to add multiple data elements and solve it like this, so you get all cases starting with a numeric value. It is not perfect but seems like the only option based on the documentation and that it does not seems possible to do something like /0*1* as it for some reason only matches /1 and /01 when tested.

 <data
    android:host="example.com"
    android:pathPattern="/0.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/1.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/2.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/3.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/4.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/5.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/6.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/7.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/8.*"
    android:scheme="https" />
<data
    android:host="example.com"
    android:pathPattern="/9.*"
    android:scheme="https" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.