From dd3eda2fd353d61ffadf0656f4f8a2ff1db8eb55 Mon Sep 17 00:00:00 2001 From: _Bastler <_Bastler@bstly.de> Date: Thu, 23 Sep 2021 10:14:35 +0200 Subject: [PATCH] add .htaccess + url parameter --- angular.json | 1 + src/.htaccess | 8 ++++++++ src/app/pages/urlshortener/urlshortener.component.ts | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 src/.htaccess diff --git a/angular.json b/angular.json index 314cc20..8b89d2b 100644 --- a/angular.json +++ b/angular.json @@ -24,6 +24,7 @@ "tsConfig": "tsconfig.app.json", "aot": true, "assets": [ + "src/.htaccess", "src/favicon.ico", "src/assets" ], diff --git a/src/.htaccess b/src/.htaccess new file mode 100644 index 0000000..fc9fbab --- /dev/null +++ b/src/.htaccess @@ -0,0 +1,8 @@ +RewriteEngine On + +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] +RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d +RewriteCond %{REQUEST_URI} !^/api/.*$ +RewriteRule ^ - [L] + +RewriteRule ^ /index.html [L] \ No newline at end of file diff --git a/src/app/pages/urlshortener/urlshortener.component.ts b/src/app/pages/urlshortener/urlshortener.component.ts index 4277ca4..7825a35 100644 --- a/src/app/pages/urlshortener/urlshortener.component.ts +++ b/src/app/pages/urlshortener/urlshortener.component.ts @@ -40,6 +40,7 @@ export class UrlShortenerComponent implements OnInit { private formBuilder: FormBuilder, private urlShortenerService: UrlShortenerService, private i18n: I18nService, + private route: ActivatedRoute, public dialog: MatDialog) { } ngOnInit(): void { @@ -65,6 +66,12 @@ export class UrlShortenerComponent implements OnInit { }) }) + this.route.queryParams.subscribe(params => { + if (params.url) { + this.shortenedUrl.url = params.url; + } + }) + this.refresh(); }