scrivito
Version:
Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.
25 lines (18 loc) • 612 B
text/typescript
// @rewire
import escape from 'lodash-es/escape';
import unescape from 'lodash-es/unescape';
import * as URI from 'urijs';
import { resolveUrl } from 'scrivito_sdk/link_resolution/resolve_url';
export function resolveHtmlUrl(encodedUrl: string): string | null {
const url = unescape(encodedUrl);
const internalUrl = resolveUrl(url);
if (!internalUrl) return null;
const newUrl = new URI(`objid:${internalUrl.obj_id}`);
if (internalUrl.fragment) {
newUrl.fragment(internalUrl.fragment);
}
if (internalUrl.query) {
newUrl.query(internalUrl.query);
}
return escape(newUrl.href());
}