mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
redirect to exclude hash from preview URL
This commit is contained in:
parent
f601cff5c5
commit
865b198ab3
1 changed files with 13 additions and 1 deletions
|
@ -152,13 +152,25 @@ export class UrlPreviewService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip out hash (anchor)
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
if (urlObj.hash) {
|
||||||
|
urlObj.hash = '';
|
||||||
|
const params = new URLSearchParams({ url: urlObj.href });
|
||||||
|
if (lang) params.set('lang', lang);
|
||||||
|
const newUrl = `/url?${params.toString()}`;
|
||||||
|
|
||||||
|
reply.redirect(newUrl, 301);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check rate limit
|
// Check rate limit
|
||||||
const auth = await this.authenticate(request);
|
const auth = await this.authenticate(request);
|
||||||
if (!await this.checkRateLimit(auth, reply)) {
|
if (!await this.checkRateLimit(auth, reply)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.utilityService.isBlockedHost(this.meta.blockedHosts, new URL(url).host)) {
|
if (this.utilityService.isBlockedHost(this.meta.blockedHosts, urlObj.host)) {
|
||||||
return reply.code(403).send({
|
return reply.code(403).send({
|
||||||
error: {
|
error: {
|
||||||
message: 'URL is blocked',
|
message: 'URL is blocked',
|
||||||
|
|
Loading…
Add table
Reference in a new issue