@tanstack/react-router 1.5.8 → 1.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ export type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>,
11
11
  export type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
12
12
  type ReplaceFirstOccurrence<T extends string, Search extends string, Replacement extends string> = T extends `${infer Prefix}${Search}${infer Suffix}` ? `${Prefix}${Replacement}${Suffix}` : T;
13
13
  export type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : ReplaceFirstOccurrence<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['types']['customId']>, ''>;
14
- export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath>;
14
+ export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? '' : ResolveFilePath<TParentRoute, TFilePath> extends `/_${infer _}` ? '' : ResolveFilePath<TParentRoute, TFilePath>;
15
15
  export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
16
16
  path: TFilePath;
17
17
  constructor(path: TFilePath);
@@ -2155,7 +2155,11 @@
2155
2155
  ...newOptions
2156
2156
  };
2157
2157
  if (!this.basepath || newOptions.basepath && newOptions.basepath !== previousOptions.basepath) {
2158
- this.basepath = `/${trimPath(newOptions.basepath ?? '') ?? ''}`;
2158
+ if (newOptions.basepath === undefined || newOptions.basepath === '' || newOptions.basepath === '/') {
2159
+ this.basepath = '/';
2160
+ } else {
2161
+ this.basepath = `/${trimPath(newOptions.basepath)}`;
2162
+ }
2159
2163
  }
2160
2164
  if (!this.history || this.options.history && this.options.history !== this.history) {
2161
2165
  this.history = this.options.history ?? (typeof document !== 'undefined' ? createBrowserHistory() : createMemoryHistory({