import * as resolver from 'url-resolve-browser' ; import { URL_PARSER_PSEUDO_DOMAIN } from './UrlParser.constants' ; export class UrlParser { url : string ; base : string ; constructor ( url , base = '/' ) { this . url = url ; this . base = base ; } checkIsAbsolutePath ( ) { const pattern = new RegExp ( '^(?:[a-z]+:)?//' , 'i' ) ; return pattern . test ( this . url ) ; } getRelativePath ( ) { const pathWithBase = resolver ( URL_PARSER_PSEUDO_DOMAIN , this . base ) ; const pathWithUrl = resolver ( pathWithBase , this . url ) ; return pathWithUrl . replace ( URL_PARSER_PSEUDO_DOMAIN , '' ) ; } }