DEV Community

Piotr Zielinski
Piotr Zielinski

Posted on

Why `/long/` and `/long` behave differently in LinkShift

I built LinkShift to help people avoid breaking links during migration.

One edge case that is easy to miss: prefix matching with a trailing slash is asymmetric.

{ "source": "/long/", "pathMatch": "prefix" }
Enter fullscreen mode Exit fullscreen mode

matches /long/abc, but it does not match /long.

By contrast:

{ "source": "/long", "pathMatch": "prefix" }
Enter fullscreen mode Exit fullscreen mode

matches /long and /long/abc.

That tiny difference matters when you are migrating old URLs. A slash in the wrong place can silently skip a rule, which is the worst kind of redirect bug.

The lesson for me was simple: redirects look trivial until the first weird edge case ships to production. Good tools need those edge cases written down, tested, and visible.

Top comments (0)