forked from trent_larson/crowd-funder-for-time-pwa
fix(deeplinks): improve DID route handling and URL encoding
- Add colon (:) to safe characters in URL encoding to preserve DID format - Add test case for simple DID route with "test" identifier - Improve test descriptions for DID-based deeplinks - Fix typo in test sequence (/d) The URL encoding now correctly handles DID format (did:ethr:0x...) while still encoding other special characters. Added basic DID test case to verify route handling before testing with actual DID values.
This commit is contained in:
@@ -54,7 +54,7 @@ urlencode() {
|
|||||||
for (( pos=0 ; pos<strlen ; pos++ )); do
|
for (( pos=0 ; pos<strlen ; pos++ )); do
|
||||||
c=${string:$pos:1}
|
c=${string:$pos:1}
|
||||||
case "$c" in
|
case "$c" in
|
||||||
[-_.~a-zA-Z0-9] ) o="${c}" ;;
|
[-_.~a-zA-Z0-9:] ) o="${c}" ;;
|
||||||
* ) printf -v o '%%%02x' "'$c"
|
* ) printf -v o '%%%02x' "'$c"
|
||||||
esac
|
esac
|
||||||
encoded+="${o}"
|
encoded+="${o}"
|
||||||
@@ -66,19 +66,20 @@ urlencode() {
|
|||||||
execute_deeplink() {
|
execute_deeplink() {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
local description="$2"
|
local description="$2"
|
||||||
local encoded_url=$(urlencode "$url")
|
|
||||||
|
|
||||||
echo -e "\n${BLUE}Testing: $description${NC}"
|
echo -e "\n${BLUE}Testing: $description${NC}"
|
||||||
|
echo -e "${YELLOW}Original URL: $url${NC}"
|
||||||
|
|
||||||
if [ "$TEST_MODE" = "print" ]; then
|
if [ "$TEST_MODE" = "print" ]; then
|
||||||
echo -e "${YELLOW}Deep Link URL:${NC}"
|
|
||||||
echo "$url"
|
|
||||||
echo -e "${YELLOW}Encoded URL:${NC}"
|
|
||||||
echo "$encoded_url"
|
|
||||||
echo "---"
|
echo "---"
|
||||||
else
|
else
|
||||||
echo "URL: $url"
|
# Stop the app before executing the deep link
|
||||||
if adb shell am start -a android.intent.action.VIEW -d "$encoded_url"; then
|
adb shell am force-stop app.timesafari.app
|
||||||
|
sleep 1 # Give it a moment to fully stop
|
||||||
|
|
||||||
|
if adb shell am start -W -a android.intent.action.VIEW \
|
||||||
|
-d "$url" \
|
||||||
|
-c android.intent.category.BROWSABLE; then
|
||||||
echo -e "${GREEN}Success: Deeplink executed${NC}"
|
echo -e "${GREEN}Success: Deeplink executed${NC}"
|
||||||
sleep "$TIMEOUT"
|
sleep "$TIMEOUT"
|
||||||
else
|
else
|
||||||
@@ -110,8 +111,11 @@ main() {
|
|||||||
"Testing raw claim addition"
|
"Testing raw claim addition"
|
||||||
|
|
||||||
# 2. DID-based deeplinks
|
# 2. DID-based deeplinks
|
||||||
|
execute_deeplink "timesafari://did/test" \
|
||||||
|
"Testing DID view with test identifier"
|
||||||
|
/d
|
||||||
execute_deeplink "timesafari://did/$CONTACT1_DID" \
|
execute_deeplink "timesafari://did/$CONTACT1_DID" \
|
||||||
"Testing DID view"
|
"Testing DID view with contact DID"
|
||||||
|
|
||||||
execute_deeplink "timesafari://contact-edit/$CONTACT1_DID" \
|
execute_deeplink "timesafari://contact-edit/$CONTACT1_DID" \
|
||||||
"Testing contact editing"
|
"Testing contact editing"
|
||||||
|
|||||||
Reference in New Issue
Block a user