Skip to content

Deprecated method used in getRedirectUrl for URL normalization #537

@Dipali127

Description

@Dipali127

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.6.1

Plugin version

8.2.0

Node.js version

22.14.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

Windows 10

Description

Description
In fastify-static, the helper function getRedirectUrl currently uses a deprecated method to extract non-slash characters from URLs.

While the current behavior works correctly, using a deprecated method is not recommended for long-term maintainability. It should be replaced with a modern approach like slice() to safely extract substrings and normalize URLs.

Expected Behavior
getRedirectUrl should normalize URLs using modern methods without relying on deprecated functionality, ensuring clean and maintainable code.

Actual Behavior
The function still uses a deprecated method to detect non-slash characters.

Link to code that reproduces the bug

https://github.com/Dipali127/fastify-static-deprecated-example/tree/main

Expected Behavior

getRedirectUrl should normalize URLs using modern methods like slice() instead of the deprecated method, ensuring the code is clean, maintainable, and future-proof.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions