![dependabot[bot]](/assets/img/avatar_default.png) 73733b20b6
			
		
	
	73733b20b6
	
	
	
		
			
			* build(deps): bump @trivago/prettier-plugin-sort-imports in /web Bumps [@trivago/prettier-plugin-sort-imports](https://github.com/trivago/prettier-plugin-sort-imports) from 2.0.4 to 3.0.0. - [Release notes](https://github.com/trivago/prettier-plugin-sort-imports/releases) - [Changelog](https://github.com/trivago/prettier-plugin-sort-imports/blob/master/CHANGELOG.md) - [Commits](https://github.com/trivago/prettier-plugin-sort-imports/commits) --- updated-dependencies: - dependency-name: "@trivago/prettier-plugin-sort-imports" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * web: update prettier config Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens.langhammer@beryju.org>
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { TemplateResult, html } from "lit";
 | |
| 
 | |
| export const SLUG_REGEX = "[-a-zA-Z0-9_]+";
 | |
| export const ID_REGEX = "\\d+";
 | |
| export const UUID_REGEX = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
 | |
| 
 | |
| export interface RouteArgs {
 | |
|     [key: string]: string;
 | |
| }
 | |
| 
 | |
| export class Route {
 | |
|     url: RegExp;
 | |
| 
 | |
|     private element?: TemplateResult;
 | |
|     private callback?: (args: RouteArgs) => TemplateResult;
 | |
| 
 | |
|     constructor(url: RegExp, element?: TemplateResult) {
 | |
|         this.url = url;
 | |
|         this.element = element;
 | |
|     }
 | |
| 
 | |
|     redirect(to: string): Route {
 | |
|         this.callback = () => {
 | |
|             console.debug(`authentik/router: redirecting ${to}`);
 | |
|             window.location.hash = `#${to}`;
 | |
|             return html``;
 | |
|         };
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     redirectRaw(to: string): Route {
 | |
|         this.callback = () => {
 | |
|             console.debug(`authentik/router: redirecting ${to}`);
 | |
|             window.location.hash = `${to}`;
 | |
|             return html``;
 | |
|         };
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     then(render: (args: RouteArgs) => TemplateResult): Route {
 | |
|         this.callback = render;
 | |
|         return this;
 | |
|     }
 | |
| 
 | |
|     render(args: RouteArgs): TemplateResult {
 | |
|         if (this.callback) {
 | |
|             return this.callback(args);
 | |
|         }
 | |
|         if (this.element) {
 | |
|             return this.element;
 | |
|         }
 | |
|         throw new Error("Route does not have callback or element");
 | |
|     }
 | |
| 
 | |
|     toString(): string {
 | |
|         return `<Route url=${this.url} callback=${this.callback ? "true" : "false"}>`;
 | |
|     }
 | |
| }
 |