1

I need to match urls ending in /*-u.html, e.g. https://www.example.com/something/whatever-u.html.

I've tried android:pathPattern="/.*-u.html", which works for the above url, but it doesn't work if there's a hyphen anywhere else in the url, e.g. https://www.example.com/some-thing/whatever-u.html. At first I thought there was something special about the hyphen character, but then I realised the same happens with any character that follows the .*.

I've tried many other combinations but can't find one to reliably match the above url format. I know that PatternMatcher is limited, but I assume it should be possible to match this?

Edit: Here's a video of the issue, using the patterns suggested in PraveenSP's answer below.

Video of the pattern not being matched

aaronmarino
  • 3,723
  • 1
  • 23
  • 36

2 Answers2

0

I think this should work:

android:pathPattern="/.*/.*-u.html"
Rediska
  • 1,392
  • 10
  • 14
0

Try to do it like this

    <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <action android:name="android.intent.action.VIEW" />
            <data
                android:host="*.yourhost.com"
                android:pathPattern="/.*\\/.*-u.html"
                android:scheme="https" />

        </intent-filter>
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <action android:name="android.intent.action.VIEW" />
            <data
                android:host="*.yourhost.com"
                android:pathPattern=".*-u.html"
                android:scheme="https" />
        </intent-filter>
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <action android:name="android.intent.action.VIEW" />
            <data
                android:host="*.yourhost.com"
                android:pathPattern="/.*\\/.*-.*-u.html"
                android:scheme="https" />

        </intent-filter>

        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <action android:name="android.intent.action.VIEW" />
            <data
                android:host="*.yourhost.com"
                android:pathPattern="/.*\\/.*-.*-u.html"
                android:scheme="https" />

        </intent-filter>

Tested cases :
https://www.example.com/some-thing/whatever-u.html
https://www.example.com/something/whatever-u.html
https://www.example.com/something/what-ever-u.html
https://www.example.com/some-thing/what-ever-u.html

AgentP
  • 6,261
  • 2
  • 31
  • 52