fix: fix router navigateUrl
Some checks failed
Build, Lint & Test Lib / Build, Lint and Test Library (push) Has been cancelled
Some checks failed
Build, Lint & Test Lib / Build, Lint and Test Library (push) Has been cancelled
This commit is contained in:
parent
0d957dfb1c
commit
3aabcd6442
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "oidc-client-rx",
|
"name": "oidc-client-rx",
|
||||||
"version": "0.1.0-alpha.5",
|
"version": "0.1.0-alpha.6",
|
||||||
"homepage": "https://github.com/lonelyhentxi/oidc-client-rx",
|
"homepage": "https://github.com/lonelyhentxi/oidc-client-rx",
|
||||||
"author": "lonelyhentxi",
|
"author": "lonelyhentxi",
|
||||||
"description": "ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications",
|
"description": "ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { InjectionToken, inject } from '@outposts/injection-js';
|
import { InjectionToken, inject } from '@outposts/injection-js';
|
||||||
import type { AnyRouter } from '@tanstack/react-router';
|
import type { AnyRouter } from '@tanstack/react-router';
|
||||||
import type { AuthFeature } from '../../features';
|
import type { AuthFeature } from '../../features';
|
||||||
import { AbstractRouter } from '../../router';
|
import { AbstractRouter, ROUTER_ABS_PATH_PATTERN } from '../../router';
|
||||||
|
|
||||||
export type TanStackRouter = AnyRouter;
|
export type TanStackRouter = AnyRouter;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ export class TanStackRouterAdapter implements AbstractRouter<string> {
|
|||||||
|
|
||||||
navigateByUrl(url: string): void {
|
navigateByUrl(url: string): void {
|
||||||
this.router.navigate({
|
this.router.navigate({
|
||||||
href: url,
|
href: ROUTER_ABS_PATH_PATTERN.test(url) ? url : `/${url}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable, inject } from '@outposts/injection-js';
|
import { Injectable, inject } from '@outposts/injection-js';
|
||||||
import { type Observable, of } from 'rxjs';
|
import { type Observable, of } from 'rxjs';
|
||||||
import { map, switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import type { AuthOptions } from '../auth-options';
|
import type { AuthOptions } from '../auth-options';
|
||||||
import { AuthStateService } from '../auth-state/auth-state.service';
|
import { AuthStateService } from '../auth-state/auth-state.service';
|
||||||
import { ConfigurationService } from '../config/config.service';
|
import { ConfigurationService } from '../config/config.service';
|
||||||
|
@ -30,6 +30,8 @@ export abstract class AbstractRouter<
|
|||||||
abstract getCurrentNavigation(): NAVIGATION;
|
abstract getCurrentNavigation(): NAVIGATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ROUTER_ABS_PATH_PATTERN = /^\//;
|
||||||
|
|
||||||
export class VanillaLocationRouter extends AbstractRouter<string> {
|
export class VanillaLocationRouter extends AbstractRouter<string> {
|
||||||
protected document = inject(DOCUMENT);
|
protected document = inject(DOCUMENT);
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ export class VanillaLocationRouter extends AbstractRouter<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigateByUrl(url: string): void {
|
navigateByUrl(url: string): void {
|
||||||
this.location.href = url;
|
this.location.href = ROUTER_ABS_PATH_PATTERN.test(url) ? url : `/${url}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentNavigation() {
|
getCurrentNavigation() {
|
||||||
@ -72,7 +74,11 @@ export class VanillaHistoryRouter extends AbstractRouter<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigateByUrl(url: string): void {
|
navigateByUrl(url: string): void {
|
||||||
this.history.pushState({}, '', url);
|
this.history.pushState(
|
||||||
|
{},
|
||||||
|
'',
|
||||||
|
ROUTER_ABS_PATH_PATTERN.test(url) ? url : `/${url}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentNavigation() {
|
getCurrentNavigation() {
|
||||||
|
Loading…
Reference in New Issue
Block a user