summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/account/account-links-regex-parser.js
blob: b6d2ad29889c1d174657486e334c50c983ef4428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { DynamicUIRequestInfo, FlowAction } from "../../api/models";
/**
 * Run a given URL through all the different web view regexes we have in the bag and return a
 * flow action with the correct page type for this url. This is essentially what AMSURLParser
 * is doing, however that does not work for App Store the way we route URLs.
 *
 * @param objectGraph The App Store object graph.
 * @param urlString The string to create the appropriate FlowAction for.
 * @returns A FlowAction appropriate for the provided URL.
 */
export function flowActionForAccountURL(objectGraph, urlString) {
    // Dynamic UI
    const dynamicUIRegexPatterns = objectGraph.bag.dynamicUIRegexStrings;
    for (const pattern of dynamicUIRegexPatterns) {
        const regexPattern = pattern.replace(/\//g, "\\/");
        const dynamicUIPattern = new RegExp(regexPattern);
        if (dynamicUIPattern.test(urlString)) {
            const action = new FlowAction("dynamicUI", urlString);
            action.pageData = new DynamicUIRequestInfo(objectGraph.bag.metricsTopic);
            return action;
        }
    }
    // Web UI regex check
    const webViewRegexPatterns = objectGraph.bag.webViewRegexStrings;
    for (const pattern of webViewRegexPatterns) {
        const regexPattern = pattern.replace(/\//g, "\\/");
        const webViewPattern = new RegExp(regexPattern);
        if (webViewPattern.test(urlString)) {
            return new FlowAction("webView", urlString);
        }
    }
    /// Last of all try to allow the finance view controller to handle this url
    return new FlowAction("finance", urlString);
}
//# sourceMappingURL=account-links-regex-parser.js.map