---
title: "Pagefind: URL encoding and selector fixes in Rust | VulCode"
description: "Three fixes to Pagefind in Rust and TypeScript: a bad selector no longer stops indexing, file URLs are percent-encoded and images keep the baseUrl domain."
url: "https://vulcode.com/en/opensource/contributions/pagefind"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

Pagefind/pagefind

# Pagefind

A Rust search engine for static sites that indexes the built site and only sends the needed parts of the index to the browser.

[See the repository](https://github.com/Pagefind/pagefind) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: Rust
- **GitHub stars**: 5,575
- **Merged changes**: 3
- **Project site**: [pagefind.app](https://pagefind.app)

## What we changed

A bad selector in --exclude-selectors no longer stops the index build, page URLs from file names with spaces, non-ASCII letters or special characters are percent-encoded, and result images from an index on another domain load from its baseUrl.

### What this work shows

- URL percent-encoding

- CSS selector parsing in lol_html

- Relative URL resolution

- In-browser integration tests

What was broken

### One bad selector crashed the whole index build

All --exclude-selectors values were joined into one selector. When lol_html could not parse one of them, for example :not(.a b), Pagefind stopped with a panic.

How we fixed it

### Each selector parsed on its own

Each selector is now parsed on its own. An unsupported one is logged as a warning and dropped, and the rest keep working. A test checks that with :not(.a b) indexing finishes and .ad is still excluded.

[#1312](https://github.com/Pagefind/pagefind/pull/1312)

What was broken

### File names went into URLs unencoded

build_url copied the file path into the URL almost verbatim and only encoded %, # and ?. A file called Müsli.html got the link /Müsli.html, and spaces or quotes in names produced invalid URLs.

How we fixed it

### Full percent-encoding of the path

The URL is encoded with the percent-encoding crate using the URL spec's path encode set, minus the slash so directory boundaries survive. Müsli.html becomes /M%C3%BCsli.html and a b/c#d?e.html becomes /a%20b/c%23d%3Fe.html.

[#1335](https://github.com/Pagefind/pagefind/pull/1335)

What was broken

### Result images loaded from the wrong domain

With an index from another domain, attached through baseUrl, result links were right, but relative images were resolved to the path alone. They loaded from the search site's domain and showed as broken.

How we fixed it

### Images keep the baseUrl domain

URL resolution now keeps the origin, in the components and in both default UI templates. An images/header.png on /blog/post/ points to https://example.com/blog/post/images/header.png. We added browser tests and a note in the resolveUrl docs.

[#1363](https://github.com/Pagefind/pagefind/pull/1363)

## Merged changes 3

- [#1363 Resolve result images against an absolute baseUrl Merged 3 November 2026](https://github.com/Pagefind/pagefind/pull/1363)

- [#1335 Percent-encode page URLs built from file paths Merged 1 November 2026](https://github.com/Pagefind/pagefind/pull/1335)

- [#1312 fix(pagefind): skip exclude selectors that cannot be parsed Merged 13 September 2026](https://github.com/Pagefind/pagefind/pull/1312)

## What it taught us

We work on both sides of a tool: in Rust at index time and in the TypeScript and Svelte interface. We know a file path is not yet a URL, and a relative address has to be resolved together with its domain.

[More about this technology: Rust](https://vulcode.com/en/technologies/rust)

## Other projects we write code for

- [**Zed** Rust · 95,562 stars A fast code editor in Rust from the creators of Atom and Tree-sitter, with live multiplayer editing.](https://vulcode.com/en/opensource/contributions/zed)

- [**uv** Rust · 92,647 stars An extremely fast Python package and project manager written in Rust. It creates projects, installs dependencies and manages virtual environments.](https://vulcode.com/en/opensource/contributions/uv)

- [**ripgrep** Rust · 70,186 stars A command line tool that recursively searches directories for a regex pattern while respecting your .gitignore. Written in Rust.](https://vulcode.com/en/opensource/contributions/ripgrep)

- [**Alacritty** Rust · 66,271 stars A cross-platform terminal emulator rendered with OpenGL, written in Rust and configured with a TOML file.](https://vulcode.com/en/opensource/contributions/alacritty)

- [**Gleam** Rust · 22,083 stars A friendly programming language for building type-safe, scalable systems. Its compiler is written in Rust.](https://vulcode.com/en/opensource/contributions/gleam)

- [**Sonic** Rust · 21,387 stars A lightweight full-text search backend in Rust, an alternative to Elasticsearch that runs in a few megabytes of RAM.](https://vulcode.com/en/opensource/contributions/sonic)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
