File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 11interface IRouterServiceParams < TRoutesConfig extends TRouterConfig > {
22 routes : TRoutesConfig ;
33 domain ?: string ;
4+ prefix ?: string ;
45}
56
67type TRouterConfig = {
Original file line number Diff line number Diff line change @@ -39,12 +39,25 @@ class Manager<TRoutesConfig extends TRouterConfig> {
3939 */
4040 protected readonly domain ?: string ;
4141
42+ /**
43+ * Url prefix (e.g. language code)
44+ */
45+ protected prefix ?: string ;
46+
4247 /**
4348 * @constructor
4449 */
45- constructor ( { routes, domain } : IRouterServiceParams < TRoutesConfig > ) {
50+ constructor ( { routes, domain, prefix } : IRouterServiceParams < TRoutesConfig > ) {
4651 this . domain = domain ;
4752 this . routes = routes ;
53+ this . prefix = prefix ;
54+ }
55+
56+ /**
57+ * Set url prefix
58+ */
59+ public setPrefix ( prefix ?: string ) : void {
60+ this . prefix = prefix ;
4861 }
4962
5063 /**
@@ -104,8 +117,9 @@ class Manager<TRoutesConfig extends TRouterConfig> {
104117 ) : string => {
105118 const path = this . getRouteUrl ( route as string , { isFullPath : true } ) ;
106119 const url = generatePath ( path , params ) ;
120+ const withPrefix = this . prefix ? `/${ this . prefix } ${ url } ` : url ;
107121
108- return hasDomain && this . domain ? `${ this . domain } ${ url } ` : url ;
122+ return hasDomain && this . domain ? `${ this . domain } ${ withPrefix } ` : withPrefix ;
109123 } ;
110124
111125 /**
You can’t perform that action at this time.
0 commit comments