Add middleware fix for responses that are not 200.
Some checks failed
Docker Image CI / build (push) Has been cancelled
Some checks failed
Docker Image CI / build (push) Has been cancelled
This commit is contained in:
parent
d36b9cf889
commit
575ae6af5a
5 changed files with 22 additions and 16 deletions
|
|
@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [2.0.67] - 2024-04-08
|
## [2.0.68] - 2024-04-09
|
||||||
|
### Changed
|
||||||
|
- Base Href middleware fix that throws error when a response is not 200.
|
||||||
|
|
||||||
|
## [2.0.67] - 2024-04-09
|
||||||
### Changed
|
### Changed
|
||||||
- Symlink fixes.
|
- Symlink fixes.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
<a class="navbar-item" routerLink="profile"> Profile </a>
|
<a class="navbar-item" routerLink="profile"> Profile </a>
|
||||||
<a class="navbar-item" (click)="logout()"> Logout </a>
|
<a class="navbar-item" (click)="logout()"> Logout </a>
|
||||||
<hr class="navbar-divider" />
|
<hr class="navbar-divider" />
|
||||||
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.67</a>
|
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.68</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "rdt-client",
|
"name": "rdt-client",
|
||||||
"version": "2.0.67",
|
"version": "2.0.68",
|
||||||
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
|
|
@ -23,20 +23,22 @@ public class BaseHrefMiddleware(RequestDelegate next, String basePath)
|
||||||
newBody.Seek(0, SeekOrigin.Begin);
|
newBody.Seek(0, SeekOrigin.Begin);
|
||||||
var responseBody = await new StreamReader(newBody).ReadToEndAsync();
|
var responseBody = await new StreamReader(newBody).ReadToEndAsync();
|
||||||
|
|
||||||
// ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
if (context.Response.StatusCode == 200)
|
||||||
if (context.Response.ContentType?.Contains("text/html") == true)
|
|
||||||
{
|
{
|
||||||
responseBody = Regex.Replace(responseBody, @"<base href=""/""", @$"<base href=""{_basePath}""");
|
if (context.Response.ContentType?.Contains("text/html") == true)
|
||||||
|
{
|
||||||
responseBody = Regex.Replace(responseBody, "(<script.*?src=\")(.*?)(\".*?</script>)", $"$1{_basePath}$2$3");
|
responseBody = Regex.Replace(responseBody, @"<base href=""/""", @$"<base href=""{_basePath}""");
|
||||||
responseBody = Regex.Replace(responseBody, "(<link.*?href=\")(.*?)(\".*?>)", $"$1{_basePath}$2$3");
|
|
||||||
|
|
||||||
context.Response.Headers.Remove("Content-Length");
|
responseBody = Regex.Replace(responseBody, "(<script.*?src=\")(.*?)(\".*?</script>)", $"$1{_basePath}$2$3");
|
||||||
await context.Response.WriteAsync(responseBody);
|
responseBody = Regex.Replace(responseBody, "(<link.*?href=\")(.*?)(\".*?>)", $"$1{_basePath}$2$3");
|
||||||
}
|
|
||||||
else
|
context.Response.Headers.Remove("Content-Length");
|
||||||
{
|
await context.Response.WriteAsync(responseBody);
|
||||||
await context.Response.BodyWriter.WriteAsync(newBody.ToArray());
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await context.Response.BodyWriter.WriteAsync(newBody.ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
||||||
<Version>2.0.67</Version>
|
<Version>2.0.68</Version>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue