aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-05-09 07:29:00 -0500
committerJP Dillingham <jp@dillingham.me>2022-05-09 07:29:00 -0500
commit9d311b82eca93e2fe0c9c60452435cbb0a010755 (patch)
treeba9494246fd6ccaff1474374f034ef8ee0cbf1d2 /src
parent35091805ce75a0d1a17d9a0c1d5faeea6be925fe (diff)
parent49d2e68ab679519c132bc2f7f97e80e34700637b (diff)
downloadslskd-9d311b82eca93e2fe0c9c60452435cbb0a010755.tar.gz
Merge remote-tracking branch 'origin/master' into search-list
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Common/Middleware/StrictUrlBaseMiddleware.cs80
-rw-r--r--src/slskd/Program.cs8
-rw-r--r--src/web/src/components/Search/Search.css14
-rw-r--r--src/web/src/config.js2
4 files changed, 9 insertions, 95 deletions
diff --git a/src/slskd/Common/Middleware/StrictUrlBaseMiddleware.cs b/src/slskd/Common/Middleware/StrictUrlBaseMiddleware.cs
deleted file mode 100644
index 7efdd171..00000000
--- a/src/slskd/Common/Middleware/StrictUrlBaseMiddleware.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// <copyright file="StrictUrlBaseMiddleware.cs" company="slskd Team">
-// Copyright (c) slskd Team. All rights reserved.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published
-// by the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see https://www.gnu.org/licenses/.
-// </copyright>
-
-namespace slskd
-{
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Http;
- using Serilog;
-
- /// <summary>
- /// Adds the <see cref="StrictUrlBaseMiddleware"/>.
- /// </summary>
- public static class StrictUrlBaseMiddlewareExtensions
- {
- /// <summary>
- /// Ensures that routes are prefixed with <paramref name="urlBase"/>.
- /// </summary>
- /// <param name="builder"></param>
- /// <param name="urlBase"></param>
- /// <returns></returns>
- public static IApplicationBuilder EnforceUrlBase(
- this IApplicationBuilder builder, string urlBase)
- {
- return builder.UseMiddleware<StrictUrlBaseMiddleware>(urlBase);
- }
- }
-
- /// <summary>
- /// Ensures that routes are prefixed with UrlBase.
- /// </summary>
- public class StrictUrlBaseMiddleware
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="StrictUrlBaseMiddleware"/> class.
- /// </summary>
- /// <param name="next"></param>
- /// <param name="urlBase"></param>
- public StrictUrlBaseMiddleware(RequestDelegate next, string urlBase)
- {
- Next = next;
- UrlBase = urlBase;
- }
-
- private ILogger Log { get; } = Serilog.Log.ForContext<StrictUrlBaseMiddleware>();
- private RequestDelegate Next { get; }
- private string UrlBase { get; }
-
- /// <summary>
- /// Executes this middleware, returning a 404 response if the path is not prefixed with UrlBase.
- /// </summary>
- /// <param name="context"></param>
- /// <returns></returns>
- public async Task InvokeAsync(HttpContext context)
- {
- if (!context.Request.Path.ToString().StartsWith(UrlBase))
- {
- Log.Debug("Request to {Path} rejected with 404; URL Base {UrlBase} is strictly enforced", context.Request.Path.ToString(), UrlBase);
- context.Response.StatusCode = 404;
- return;
- }
-
- await Next(context);
- }
- }
-} \ No newline at end of file
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 94cd0eba..c815af41 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -603,13 +603,7 @@ namespace slskd
var urlBase = OptionsAtStartup.Web.UrlBase;
urlBase = urlBase.StartsWith("/") ? urlBase : "/" + urlBase;
- // 404 if a custom urlBase is set, but the request doesn't include it.
- // this is necessary to make sure the development-time and run-time behavior
- // are consistent.
- app.EnforceUrlBase(urlBase);
-
- // use urlBase. this effectively just removes urlBase from the path, which is
- // why the enforcement behavior exists above (the actually requested path becomes ambiguous)
+ // use urlBase. this effectively just removes urlBase from the path.
// inject urlBase into any html files we serve, and rewrite links to ./static or /static to
// prepend the url base.
app.UsePathBase(urlBase);
diff --git a/src/web/src/components/Search/Search.css b/src/web/src/components/Search/Search.css
index 76079ee9..10d7c15f 100644
--- a/src/web/src/components/Search/Search.css
+++ b/src/web/src/components/Search/Search.css
@@ -21,8 +21,8 @@
margin-right: auto !important;
}
-@media only screen and (min-width: 851px) {
- .search-options-hide-no-slots, .search-options-hide-locked {
+@media only screen and (min-width: 991px) {
+ .search-options-hide-no-slots, .search-options-hide-locked, .search-options-fold-results {
margin-left: 1rem;
}
@@ -31,28 +31,28 @@
}
}
-@media only screen and (max-width: 850px) {
+@media only screen and (max-width: 685px) {
.search-options-sort {
width: 100%;
}
}
-@media only screen and (max-width: 850px) {
+@media only screen and (max-width: 990px) {
.search-option-toggles {
margin-top: 1rem;
}
- .search-options-hide-no-slots {
+ .search-options-hide-no-slots, .search-options-fold-results {
margin-left: 1rem;
}
}
-@media only screen and (max-width: 537px) {
+@media only screen and (max-width: 684px) {
.search-option-toggles {
display: grid;
}
- .search-options-hide-no-slots {
+ .search-options-hide-no-slots, .search-options-fold-results {
margin-top: 1rem;
margin-left: 0px;
}
diff --git a/src/web/src/config.js b/src/web/src/config.js
index ca9f58b2..8b1c40c6 100644
--- a/src/web/src/config.js
+++ b/src/web/src/config.js
@@ -1,5 +1,5 @@
const urlBase = (window.urlBase === '/' ? '' : window.urlBase) || '';
-const rootUrl = process.env.NODE_ENV === 'production' ? urlBase : `http://localhost:5000/${urlBase}`;
+const rootUrl = process.env.NODE_ENV === 'production' ? urlBase : `http://localhost:5000${urlBase}`;
const apiBaseUrl = `${rootUrl}/api/v0`;
const hubBaseUrl = `${rootUrl}/hub`;
const tokenKey = 'slskd-token';