Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android deeplinking: match url only when no path

Given the following URLS:

1. www.example.com

2. www.example.com/a

Via deeplinking, I want my app to only react on 1 and not 2.

            <data
                android:host="*.example.com"
                android:pathPrefix="/"
                android:scheme="http"/>

This will, of course, catch all www.example.com/... urls, how can I match only www.example.com without any path and not match www.example.com/a?

like image 480
fweigl Avatar asked Sep 01 '16 08:09

fweigl


2 Answers

Here's what worked for me, set path empty and include a tools:ignore to avoid lint errors.

<data
     android:host="*.example.com"
     android:path=""
     android:scheme="http"
     tools:ignore="AppLinkUrlError"
            />
like image 147
CodeSmith Avatar answered Sep 28 '22 00:09

CodeSmith


Using 'path' instead of 'pathPrefix' or 'pathPattern' worked, so:

        <data
            android:host="*.example.com"
            android:path="/"
            android:scheme="http"/>

matches www.example.com as well as www.example.com/, but not www.example.com/a, so exactly what I wanted.

like image 32
fweigl Avatar answered Sep 28 '22 01:09

fweigl