module

KemalIdentity::Kemal::PathPrefix

Whether a path is inside a prefix's subtree.

Public because an application writing its own handler needs exactly this rule, and the tempting one-liner is wrong: path.starts_with?("/admin") also matches /administrators, which hands an attacker an unguarded path that looks guarded. One implementation rather than two that almost agree — PathGuard and ErrorHandler both ask here.

Class methods

covers?(prefix : String, path : String) : Bool

/admin covers /admin, /admin/ and /admin/users, and not /administrators. A prefix of / covers everything.

Source
normalise(prefix : String) : String

Normalises a configured prefix: "/admin/" and "/admin" are the same subtree rather than two subtly different ones. Raises for a prefix that is not a path.

Source