A Plus Sign in an Asset URL Path Resolves to the Wrong Asset
Level 2 · node · API · Confusing plus signs with spaces in URL path segments
Scenario
A fictional facility asset service looks up assets by an identifier supplied as a URL path segment. Both spaces and plus signs are valid and distinct characters in asset identifiers. The current API treats a plus sign in the path as a space, so requesting 'panel+A' incorrectly returns the 'panel A' asset. Inspect how the routing and lookup layers decode the path.
Requirements
Preserve a literal plus sign in a URL path segment, and decode '%2B' as a plus sign. Decode '%20' as a space. Look up the exact asset identifier and return 404 for unknown identifiers, while preserving ordinary lookups.
Acceptance criteria
- An alphanumeric and hyphenated asset identifier resolves correctly.
- A percent-encoded space (%20) resolves the asset whose identifier contains a space.
- A literal plus sign (+) in a path resolves the asset with a plus sign, not a space.
- A percent-encoded plus sign (%2B) resolves the asset with a plus sign.
- An unknown asset identifier returns HTTP 404.