@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
10 lines • 1.31 kB
JavaScript
/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import"./boot.js";let e,r,t=/(url\()([^)]*)(\))/g,n=/(^\/[^\/])|(^#)|(^[\w-\d]*:)/;export function resolveUrl(t,a){if(t&&n.test(t))return t;if("//"===t)return t;if(void 0===e){e=!1;try{const r=new URL("b","http://a");r.pathname="c%20d",e="http://a/c%20d"===r.href}catch(e){}}if(a||(a=document.baseURI||window.location.href),e)try{return new URL(t,a).href}catch(e){return t}return r||(r=document.implementation.createHTMLDocument("temp"),r.base=r.createElement("base"),r.head.appendChild(r.base),r.anchor=r.createElement("a"),r.body.appendChild(r.anchor)),r.base.href=a,r.anchor.href=t,r.anchor.href||t}export function resolveCss(e,r){return e.replace(t,(function(e,t,n,a){return t+"'"+resolveUrl(n.replace(/["']/g,""),r)+"'"+a}))}export function pathFromUrl(e){return e.substring(0,e.lastIndexOf("/")+1)}