diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs index 2ee014f..5bcbd62 100644 --- a/src/config.rs +++ b/src/config.rs @@ -123,6 +123,9 @@ pub struct MiniserveConfig { /// If enabled, display a wget command to recursively download the current directory pub show_wget_footer: bool, + /// If enabled, render the readme from the current directory + pub readme: bool, + /// If set, use provided rustls config for TLS #[cfg(feature = "tls")] pub tls_rustls_config: Option<rustls::ServerConfig>, @@ -151,8 +154,20 @@ impl MiniserveConfig { // Generate some random routes for the favicon and css so that they are very unlikely to conflict with // real files. - let favicon_route = format!("/{}", nanoid::nanoid!(10, &ROUTE_ALPHABET)); - let css_route = format!("/{}", nanoid::nanoid!(10, &ROUTE_ALPHABET)); + // If --random-route is enabled , in order to not leak the random generated route, we must not use it + // as static files prefix. + // Otherwise, we should apply route_prefix to static files. + let (favicon_route, css_route) = if args.random_route { + ( + format!("/{}", nanoid::nanoid!(10, &ROUTE_ALPHABET)), + format!("/{}", nanoid::nanoid!(10, &ROUTE_ALPHABET)), + ) + } else { + ( + format!("{}/{}", route_prefix, nanoid::nanoid!(10, &ROUTE_ALPHABET)), + format!("{}/{}", route_prefix, nanoid::nanoid!(10, &ROUTE_ALPHABET)), + ) + }; let default_color_scheme = args.color_scheme; let default_color_scheme_dark = args.color_scheme_dark; @@ -244,6 +259,7 @@ impl MiniserveConfig { hide_version_footer: args.hide_version_footer, hide_theme_selector: args.hide_theme_selector, show_wget_footer: args.show_wget_footer, + readme: args.readme, tls_rustls_config: tls_rustls_server_config, }) } |