MCPcopy
hub / github.com/rapi-doc/RapiDoc / getComponentBaseURL

Method getComponentBaseURL

src/rapidoc.js:820–837  ·  view source on GitHub ↗

* Return the URL from where is served the RapiDoc component, removing any hash and route prefix

()

Source from the content-addressed store, hash-verified

818 * Return the URL from where is served the RapiDoc component, removing any hash and route prefix
819 */
820 getComponentBaseURL() {
821 const { href } = window.location;
822
823 // Remove end of string # or /
824 const cleanRouterPrefix = this.routePrefix.replace(/(#|\/)$/, '');
825
826 if (!cleanRouterPrefix) {
827 return href.split('#')[0];
828 }
829
830 const indexOfRoutePrefix = href.lastIndexOf(cleanRouterPrefix);
831
832 if (indexOfRoutePrefix === -1) {
833 return href;
834 }
835
836 return href.slice(0, indexOfRoutePrefix);
837 }
838
839 /**
840 * From the URL return the ID of the element whether it is in the hash or if used a router prefix without a hash

Callers 2

getElementIDFromURLMethod · 0.95
replaceHistoryStateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected