index.js 579 Bytes
import jumpToMiniapp from './jump-to-miniapp';
import {parse, stringify} from '../vendors/query-string';

const MINI_APP_DOMAIN = 'miniapp.yohobuy.com';

global.router = {
    goUrl(url) {
        if (!url) {
            return Promise.reject('error url');
        }

        const [uri, search] = url.split('?');
        const path = uri.split(MINI_APP_DOMAIN)[1];
        const qs = parse(search);

        if (qs.app && path) {
            return jumpToMiniapp({
                app: qs.app,
                path: `${path}?${stringify(qs)}`
            });
        }
    }
};