Worklog for task "Fix URL decoding in haih-agent"

27 авг. 2026 г., 03:08:32

Clarification on URI Decoding

After verification, it turned out that decodeURI(asPath) does not cover all the necessary cases.

Concrete example:

/projects/%40prisma-cms/sendmail

is expected to be:

/projects/@prisma-cms/sendmail

However, decodeURI() leaves %40 intact because @ belongs to reserved URI characters, and the entire URI is not fully decoded.

For entity URIs, it is more correct to process the path segment by segment:

  1. First, split the pathname by /, preserving the route structure.
  2. Pass each segment separately through decodeURIComponent().
  3. Reassemble the path.

This way, we get the required decoding %40 -> @ without the risk that an encoded %2F inside a single slug prematurely turns into a structural / and changes the number of route segments.

In other words, the target logic should be segment-aware, for example conceptually:

const uri = pathname
  .split('/')
  .map(segment => decodeURIComponent(segment))
  .join('/')

This is also symmetrical to the current implementation of slugifyUri(), which already works on a segment-by-segment basis.

The current decodeURI(asPath) can be considered an interim fix: it solves cases like %22, but not %40 and other reserved characters if they are part of a slug/entity URI.

A separate URIError is not considered here as part of this task: technical malformed URL errors should be handled separately.

27.08.2026

Add proper URL/route params decoding in haih-agent so that percent-encoded special characters do not lead to false 404 errors.