Deep-link scaffolding
Summary: This change adds the necessary scaffolding to enable deep-link for PWA. 1. Registers the protocol/scheme in the manifest.json 2. Add a skeleton handler that parses the received arguments Notes for reviewers: PWA cannot reuse the 'flipper://' scheme as is not allowed. PWA schemes are limited. The only extension point is 'web+...' which is the one that is used. Reviewed By: antonk52 Differential Revision: D48562301 fbshipit-source-id: e191fcb1a6604d20a55c1acdadf6a8eb0194895b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1360e906f8
commit
aa327b1a46
@@ -38,6 +38,25 @@ async function start() {
|
|||||||
token = manifest.token;
|
token = manifest.token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openPlugin = params.get('open-plugin');
|
||||||
|
if (openPlugin) {
|
||||||
|
function removePrefix(input: string, prefix: string): string {
|
||||||
|
const regex = new RegExp(`^${prefix}+`);
|
||||||
|
return input.replace(regex, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(openPlugin);
|
||||||
|
const maybeParams = removePrefix(url.pathname, '/');
|
||||||
|
const params = new URLSearchParams(maybeParams);
|
||||||
|
|
||||||
|
const queryParamsObject: any = {};
|
||||||
|
params.forEach((value, key) => {
|
||||||
|
queryParamsObject[key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(JSON.stringify(queryParamsObject));
|
||||||
|
}
|
||||||
|
|
||||||
const searchParams = new URLSearchParams({token: token ?? ''});
|
const searchParams = new URLSearchParams({token: token ?? ''});
|
||||||
|
|
||||||
const flipperServer = await createFlipperServer(
|
const flipperServer = await createFlipperServer(
|
||||||
|
|||||||
@@ -24,5 +24,11 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"protocol_handlers": [
|
||||||
|
{
|
||||||
|
"protocol": "web+flipper",
|
||||||
|
"url": "/?open-plugin=%s"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user