Skip to content

Instantly share code, notes, and snippets.

@ShapeGroup
Last active September 26, 2021 10:08
Show Gist options
  • Save ShapeGroup/6c55e3305b0445a0801806b1f0515fe1 to your computer and use it in GitHub Desktop.
Save ShapeGroup/6c55e3305b0445a0801806b1f0515fe1 to your computer and use it in GitHub Desktop.
js-kit-pathfinder
//// JS KIT - PATHS FINDER
//// MIT LICENCE
//// Credit: alberto marà
// how to use:
// <img src="'+this.resouces+'images/imagename.svg" />;
class PATHFINDER
{
constructor()
{
this.pathanalyzer();
}
pathanalyzer()
{
this.url = String(window.location);
this.islocal = this.url.includes('dev-') ? true : false;
this.protocol = this.url.includes('https') ? 'https' : 'http';
this.hostname = this.url.split(this.protocol+"://")[1].split("/")[0];
this.basehost = this.protocol+"://"+this.hostname+'/';
this.pagename = this.url.split("/").pop().split("?")[0];
this.resouces = this.basehost+'resources/';
}
}
const paths = new PATHFINDER();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment