export enum LinkType { RELATIVE, ROOT, ABSOLUTE } export class Link { type:LinkType; path:string; clone() { let c = new Link(); c.type = this.type; c.path = this.path; return c; } prettify() { let clone = this.clone(); if ( clone.path.endsWith( "index.php" ) ) { clone.path = clone.path.replace( /index\.php$/, "" ); } if ( clone.path.endsWith( ".php" ) ) { clone.path = clone.path.replace( /\.php$/, "" ); } if ( clone.path.endsWith( "/" ) ) { clone.path = clone.path.replace( /\/$/, "" ); } return clone; } static Root( path:string ) { let c = new Link(); c.type = LinkType.ROOT; c.path = path; return c; } static Absolute( path:string ) { let c = new Link(); c.type = LinkType.ABSOLUTE; c.path = path; return c; } static Relative( path:string ) { let c = new Link(); c.type = LinkType.RELATIVE; c.path = path; return c; } }