@shopify/app-bridge-host
Version:
App Bridge Host contains middleware and components that are meant to be consumed by the app's host. The middleware and `Frame` component are responsible for facilitating messages posted between the client and host, and used to act on actions sent from the
31 lines (30 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var resolver_1 = require("../Navigation/utilities/resolver");
/**
* Build an app URL from an initial URL and a path
* @internal
* As a precautionary measure the `path` will be stripped off a host if one is
* given.
*/
function buildAppUrl(_a) {
var handle = _a.handle, initialUrl = _a.url, apiKey = _a.apiKey, pathname = _a.pathname, _b = _a.search, search = _b === void 0 ? undefined : _b;
var url = new URL(initialUrl);
var intermediatePath = new URL(pathname, url.origin).pathname;
var appPath = intermediatePath.replace(new RegExp(resolver_1.APPS_URL + "/(" + handle + "|" + apiKey + ")"), '');
if (appPath !== '' && appPath !== '/') {
url.pathname = appPath;
}
if (search !== undefined) {
url.search = search;
}
return url;
}
exports.buildAppUrl = buildAppUrl;
/**
* Convert: 'some/path' to '/some/path'
*/
function normalizeRelativePath(path) {
return path[0] === '/' ? path : "/" + path;
}
exports.normalizeRelativePath = normalizeRelativePath;