Home / Function/ buildRoutePrefix() — fastify Function Reference

buildRoutePrefix() — fastify Function Reference

Architecture documentation for the buildRoutePrefix() function in plugin-override.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  f25fe79a_ed94_8b5c_60ec_32b8b7b414e0["buildRoutePrefix()"]
  be24bd7b_f1cd_889a_75cb_83e4cace8260["plugin-override.js"]
  f25fe79a_ed94_8b5c_60ec_32b8b7b414e0 -->|defined in| be24bd7b_f1cd_889a_75cb_83e4cace8260
  8f032db4_406b_2857_6dbc_0f64d681afb5["module()"]
  8f032db4_406b_2857_6dbc_0f64d681afb5 -->|calls| f25fe79a_ed94_8b5c_60ec_32b8b7b414e0
  style f25fe79a_ed94_8b5c_60ec_32b8b7b414e0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/plugin-override.js lines 76–90

function buildRoutePrefix (instancePrefix, pluginPrefix) {
  if (!pluginPrefix) {
    return instancePrefix
  }

  // Ensure that there is a '/' between the prefixes
  if (instancePrefix.endsWith('/') && pluginPrefix[0] === '/') {
    // Remove the extra '/' to avoid: '/first//second'
    pluginPrefix = pluginPrefix.slice(1)
  } else if (pluginPrefix[0] !== '/') {
    pluginPrefix = '/' + pluginPrefix
  }

  return instancePrefix + pluginPrefix
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does buildRoutePrefix() do?
buildRoutePrefix() is a function in the fastify codebase, defined in lib/plugin-override.js.
Where is buildRoutePrefix() defined?
buildRoutePrefix() is defined in lib/plugin-override.js at line 76.
What calls buildRoutePrefix()?
buildRoutePrefix() is called by 1 function(s): module.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free