Upstream Pagefind/pagefind state of the touched files before dfc8664a11

This commit is contained in:
upstream committed 2026-09-11 23:07:10 +02:00
1 parent 49fb9b1b9b
commit 3d8f53f964
3 files changed
+1 -48

No files matched your search

Generated
-1
View File
@@ -2303,7 +2303,6 @@ dependencies = [
"minifier",
"pagefind_stem 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"path-slash",
"percent-encoding",
"portpicker",
"rayon",
"regex",
-1
View File
@@ -90,7 +90,6 @@ actix-web = { version = "4", optional = true }
actix-files = { version = "0.7", optional = true }
lexical-core = "1.0.0"
path-slash = "0.2"
percent-encoding = "2"
rayon = "1.10"
rust-patch = "0.1.3"
typed-builder = "0.23.2"
+1 -46
View File
@@ -7,7 +7,6 @@ use hashbrown::HashMap;
use lazy_static::lazy_static;
use pagefind_stem::{Algorithm, Stemmer};
use path_slash::PathExt as _;
use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
use regex::Regex;
use std::collections::BTreeMap;
use std::io::BufRead;
@@ -590,22 +589,6 @@ impl Fossicker {
}
/// The URL spec's path percent-encode set, minus `/` so that the separators
/// between the path segments survive. `%`, `#` and `?` are already encoded one
/// by one today; the rest of the set covers the remaining characters that a
/// file name can carry but a URL path cannot, such as a space or a quote.
const PATH_ENCODE_SET: &AsciiSet = &CONTROLS
.add(b' ')
.add(b'"')
.add(b'#')
.add(b'%')
.add(b'<')
.add(b'>')
.add(b'?')
.add(b'`')
.add(b'{')
.add(b'}');
fn strip_index_html(url: &str) -> &str {
if url.ends_with("/index.html") {
&url[..url.len() - 10]
@@ -638,7 +621,7 @@ fn build_url(page_url: &Path, relative_to: Option<&Path>, options: &SearchOption
url.to_slash_lossy().to_owned().to_string()
};
format!("/{}", utf8_percent_encode(&final_url, PATH_ENCODE_SET))
format!("/{}", final_url)
}
fn normalize_content(content: &str) -> String {
@@ -1262,34 +1245,6 @@ mod tests {
let p: PathBuf = cwd.join::<PathBuf>("hello/world/index.html".into());
let root: PathBuf = cwd.join::<PathBuf>("hello".into());
assert_eq!(&build_url(&p, Some(&root), &opts), "/world/");
let p: PathBuf = cwd.join::<PathBuf>("hello/world/100%/C#/why?.html".into());
assert_eq!(&build_url(&p, None, &opts), "/100%25/C%23/why%3F.html");
}
#[cfg(not(target_os = "windows"))]
#[test]
fn building_urls_with_characters_that_need_encoding() {
std::env::set_var("PAGEFIND_SITE", "hello/world");
let config =
PagefindInboundConfig::with_layers(&[Layer::Env(Some("PAGEFIND_".into()))]).unwrap();
let opts = SearchOptions::load(config).unwrap();
let cwd = std::env::current_dir().unwrap();
let p: PathBuf = cwd.join::<PathBuf>("hello/world/Müsli.html".into());
assert_eq!(&build_url(&p, None, &opts), "/M%C3%BCsli.html");
let p: PathBuf = cwd.join::<PathBuf>("hello/world/Müsli/index.html".into());
assert_eq!(&build_url(&p, None, &opts), "/M%C3%BCsli/");
let p: PathBuf = cwd.join::<PathBuf>("hello/world/a b/c#d?e.html".into());
assert_eq!(&build_url(&p, None, &opts), "/a%20b/c%23d%3Fe.html");
// A literal percent in the file name is encoded, so the URL points back at
// the file that is on disk rather than at the one it looks like it names.
let p: PathBuf = cwd.join::<PathBuf>("hello/world/M%C3%BCsli.html".into());
assert_eq!(&build_url(&p, None, &opts), "/M%25C3%25BCsli.html");
}
#[cfg(target_os = "windows")]