diff --git a/package.json b/package.json index 7161909c..e9dd09ec 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "url": "https://github.com/bpatrik/PiGallery2/issues" }, "dependencies": { - "archiver": "^5.3.0", + "archiver": "5.3.0", "bcrypt": "5.0.1", "body-parser": "1.19.0", "cookie-parser": "1.4.5", @@ -78,7 +78,7 @@ "@asymmetrik/ngx-leaflet": "8.1.0", "@asymmetrik/ngx-leaflet-markercluster": "5.0.1", "@ngx-loading-bar/core": "5.1.1", - "@types/archiver": "^5.1.0", + "@types/archiver": "5.1.0", "@types/bcrypt": "3.0.1", "@types/bcryptjs": "2.4.2", "@types/chai": "4.2.16", @@ -126,7 +126,7 @@ "karma-jasmine-html-reporter": "1.5.4", "karma-remap-istanbul": "0.6.0", "karma-systemjs": "0.16.0", - "leaflet": "^1.7.1", + "leaflet": "1.7.1", "leaflet.markercluster": "1.5.0", "mocha": "8.3.2", "natural-orderby": "2.0.3", diff --git a/src/backend/routes/GalleryRouter.ts b/src/backend/routes/GalleryRouter.ts index 8aa35545..99780f7a 100644 --- a/src/backend/routes/GalleryRouter.ts +++ b/src/backend/routes/GalleryRouter.ts @@ -196,7 +196,7 @@ export class GalleryRouter { } protected static addSearch(app: Express): void { - app.get('/api/search/:searchQueryDTO', + app.get('/api/search/:searchQueryDTO(*)', // common part AuthenticationMWs.authenticate, AuthenticationMWs.authorise(UserRoles.Guest), @@ -212,7 +212,7 @@ export class GalleryRouter { protected static addAutoComplete(app: Express): void { - app.get('/api/autocomplete/:text', + app.get('/api/autocomplete/:text(*)', // common part AuthenticationMWs.authenticate, AuthenticationMWs.authorise(UserRoles.Guest), diff --git a/src/frontend/app/ui/gallery/search/autocomplete.service.ts b/src/frontend/app/ui/gallery/search/autocomplete.service.ts index 231072d4..2c18dce1 100644 --- a/src/frontend/app/ui/gallery/search/autocomplete.service.ts +++ b/src/frontend/app/ui/gallery/search/autocomplete.service.ts @@ -68,17 +68,21 @@ export class AutoCompleteService { items = items || new BehaviorSubject([]); const cached = this.galleryCacheService.getAutoComplete(text, type); - if (cached == null) { - const acParams: any = {}; - if (type) { - acParams[QueryParams.gallery.search.type] = type; + try { + if (cached == null) { + const acParams: any = {}; + if (type) { + acParams[QueryParams.gallery.search.type] = type; + } + this.networkService.getJson('/autocomplete/' + text, acParams).then(ret => { + this.galleryCacheService.setAutoComplete(text, type, ret); + items.next(this.sortResults(text, ret.map(i => this.ACItemToRenderable(i, fullText)).concat(items.value))); + }); + } else { + items.next(this.sortResults(text, cached.map(i => this.ACItemToRenderable(i, fullText)).concat(items.value))); } - this.networkService.getJson('/autocomplete/' + text, acParams).then(ret => { - this.galleryCacheService.setAutoComplete(text, type, ret); - items.next(this.sortResults(text, ret.map(i => this.ACItemToRenderable(i, fullText)).concat(items.value))); - }); - } else { - items.next(this.sortResults(text, cached.map(i => this.ACItemToRenderable(i, fullText)).concat(items.value))); + } catch (e) { + console.error(e); } return items; }