Repository: static-web-server/static-web-server (language: rust)

Issue:
URL Rewrites without placeholders do not work 
**Describe the bug**
I have a config containing rewrites without capture groups like this:
``` toml
  [advanced]

  [[advanced.rewrites]]
  source = "/content/images/login.jpg"
  destination = "/content/images/brands/demo/login.jpg"
```
These work fine in version 2.19, but no longer seem to work in 2.20.


**To Reproduce**
1. configure a rewrite with static paths like
	``` toml
      [advanced]

	  [[advanced.rewrites]]
	  source = "/content/images/login.jpg"
	  destination = "/content/images/brands/demo/login.jpg"
	```
2. call the path to be rewritten

**Expected behavior**
The path should be rewritten to the destination value.

**Environment and Specs**
 - static-web-server: v2.20.0
 - OS: Ubuntu 22.04.2 , kernel: 5.15.0-76-generic
 - Docker: containerd://1.6.21
 - Client: Chrome 114.0.5735.199

**Additional context**
I believe this may have been caused by https://github.com/static-web-server/static-web-server/pull/235/files#diff-eeb37db412eaa35c05c4a14c09cba43f9aae572c5da79fa31a2170d2665e307c. It looks to me like the new behaviour requires capture groups to exist within the source.

URL Rewrites without placeholders do not work 
**Describe the bug**
I have a config containing rewrites without capture groups like this:
``` toml
  [advanced]

  [[advanced.rewrites]]
  source = "/content/images/login.jpg"
  destination = "/content/images/brands/demo/login.jpg"
```
These work fine in version 2.19, but no longer seem to work in 2.20.


**To Reproduce**
1. configure a rewrite with static paths like
	``` toml
      [advanced]

	  [[advanced.rewrites]]
	  source = "/content/images/login.jpg"
	  destination = "/content/images/brands/demo/login.jpg"
	```
2. call the path to be rewritten

**Expected behavior**
The path should be rewritten to the destination value.

**Environment and Specs**
 - static-web-server: v2.20.0
 - OS: Ubuntu 22.04.2 , kernel: 5.15.0-76-generic
 - Docker: containerd://1.6.21
 - Client: Chrome 114.0.5735.199

**Additional context**
I believe this may have been caused by https://github.com/static-web-server/static-web-server/pull/235/files#diff-eeb37db412eaa35c05c4a14c09cba43f9aae572c5da79fa31a2170d2665e307c. It looks to me like the new behaviour requires capture groups to exist within the source.



Discussion / hints:
This should impact URL Redirects as well. However, it should be easy to be fixed.
This should impact URL Redirects as well. However, it should be easy to be fixed.

Fix patch:
diff --git a/src/settings/mod.rs b/src/settings/mod.rs
index 9b165f2d..71ab5ea0 100644
--- a/src/settings/mod.rs
+++ b/src/settings/mod.rs
@@ -333,11 +333,8 @@ impl Settings {
                                     })?
                                     .compile_matcher();
 
-                                // NOTE: we don’t need Unicode-aware word boundary assertions,
-                                // therefore we use (?-u:\b) instead of (?-u)
-                                // so the former uses an ASCII-only definition of a word character.
-                                // https://docs.rs/regex/latest/regex/#unicode-can-impact-memory-usage-and-search-speed
-                                let pattern = source.glob().regex().replace("(?-u)^", "(?-u:\\b)");
+                                let pattern =
+                                    source.glob().regex().trim_start_matches("(?-u)").to_owned();
                                 tracing::debug!(
                                     "url rewrites glob pattern: {}",
                                     &rewrites_entry.source
@@ -378,11 +375,8 @@ impl Settings {
                                     })?
                                     .compile_matcher();
 
-                                // NOTE: we don’t need Unicode-aware word boundary assertions,
-                                // therefore we use (?-u:\b) instead of (?-u)
-                                // so the former uses an ASCII-only definition of a word character.
-                                // https://docs.rs/regex/latest/regex/#unicode-can-impact-memory-usage-and-search-speed
-                                let pattern = source.glob().regex().replace("(?-u)^", "(?-u:\\b)");
+                                let pattern =
+                                    source.glob().regex().trim_start_matches("(?-u)").to_owned();
                                 tracing::debug!(
                                     "url rewrites glob pattern: {}",
                                     &redirects_entry.source


Test patch:
diff --git a/tests/toml/config.toml b/tests/toml/config.toml
index fe9849ba..07964266 100644
--- a/tests/toml/config.toml
+++ b/tests/toml/config.toml
@@ -108,11 +108,21 @@ kind = 302
 
 ### URL Rewrites
 
+[[advanced.rewrites]]
+source = "/image.ico"
+destination = "/assets/favicon.ico"
+# redirect = 301
+
+[[advanced.rewrites]]
+source = "/{picture}.{ico,webp}"
+destination = "/assets/$1.$2"
+# redirect = 301
+
 [[advanced.rewrites]]
 source = "**/{*}.{png,gif}"
 destination = "/assets/$1.$2"
 # redirect = 301
 
 [[advanced.rewrites]]
-source = "**/*.{jpg,jpeg}"
+source = "/abc/**/*.{svg,jxl}"
 destination = "/assets/favicon.ico"