@@ -41,7 +41,8 @@ export abstract class HttpUrlGenerator {
4141 * Return the base URL for a single entity resource,
4242 * e.g., the base URL to get a single hero by its id
4343 */
44- abstract entityResource ( entityName : string , root : string ) : string ;
44+ abstract entityResource ( entityName : string , root : string ,
45+ trailingSlashEndpoints : boolean ) : string ;
4546
4647 /**
4748 * Return the base URL for a collection resource,
@@ -77,11 +78,12 @@ export class DefaultHttpUrlGenerator implements HttpUrlGenerator {
7778 */
7879 protected getResourceUrls (
7980 entityName : string ,
80- root : string
81+ root : string ,
82+ trailingSlashEndpoints : boolean = false
8183 ) : HttpResourceUrls {
8284 let resourceUrls = this . knownHttpResourceUrls [ entityName ] ;
8385 if ( ! resourceUrls ) {
84- const nRoot = normalizeRoot ( root ) ;
86+ const nRoot = trailingSlashEndpoints ? root : normalizeRoot ( root ) ;
8587 resourceUrls = {
8688 entityResourceUrl : `${ nRoot } /${ entityName } /` . toLowerCase ( ) ,
8789 collectionResourceUrl : `${ nRoot } /${ this . pluralizer . pluralize (
@@ -99,8 +101,9 @@ export class DefaultHttpUrlGenerator implements HttpUrlGenerator {
99101 * @param root {string} Root path to the resource, e.g., 'some-api`
100102 * @returns complete path to resource, e.g, 'some-api/hero'
101103 */
102- entityResource ( entityName : string , root : string ) : string {
103- return this . getResourceUrls ( entityName , root ) . entityResourceUrl ;
104+ entityResource ( entityName : string , root : string ,
105+ trailingSlashEndpoints : boolean ) : string {
106+ return this . getResourceUrls ( entityName , root , trailingSlashEndpoints ) . entityResourceUrl ;
104107 }
105108
106109 /**
0 commit comments