{"record":{"id":"4d43f1bc95f27ced","repo":"ruby-grape/grape","slug":"grape-router-normalize-path-is-deprecated-use","errorCode":null,"errorMessage":"`Grape::Router.normalize_path` is deprecated. Use `Grape::Util::PathNormalizer.call` instead.","messagePattern":"`Grape::Router\\.normalize_path` is deprecated\\. Use `Grape::Util::PathNormalizer\\.call` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/grape/router.rb","lineNumber":7,"sourceCode":"# frozen_string_literal: true\n\nmodule Grape\n  class Router\n    # @deprecated Use {Grape::Util::PathNormalizer.call} instead.\n    def self.normalize_path(path)\n      Grape.deprecator.warn(\n        '`Grape::Router.normalize_path` is deprecated. Use `Grape::Util::PathNormalizer.call` instead.'\n      )\n      Grape::Util::PathNormalizer.call(path)\n    end\n\n    def initialize\n      @neutral_map = []\n      @neutral_regexes = []\n      # Plain hashes with no auto-vivifying default: a lookup for an HTTP method\n      # that has no routes must not insert a key. `compile!` freezes both maps,\n      # so request-time reads never mutate shared state (see #match? / #rotation).\n      @map = {}\n      @optimized_map = {}\n    end\n\n    def compile!\n      return if @compiled\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/ruby-grape/grape/blob/22d7975629846a3c0c7bd2b34e140a7a1b4af8f6/lib/grape/router.rb#L1-L25","documentation":"`Grape::Router.normalize_path` moved to `Grape::Util::PathNormalizer.call`. The class-method shim remains for compatibility: it warns via `Grape.deprecator` and delegates to the new implementation, but it will be removed in a future release.","triggerScenarios":"Calling `Grape::Router.normalize_path('/foo//bar/')` in initializers, specs, or helper gems that pre-normalize endpoint paths before registering them with Grape.","commonSituations":"Code that reached into Grape internals to normalize paths; third-party mounting gems or copied snippets calling the old class method after an upgrade.","solutions":["Replace the call with `Grape::Util::PathNormalizer.call(path)`","If you support multiple Grape versions, branch on the constant: use PathNormalizer when defined, else the old method"],"exampleFix":"# before\nGrape::Router.normalize_path('/foo//bar/')\n\n# after\nGrape::Util::PathNormalizer.call('/foo//bar/')","handlingStrategy":"fallback","validationCode":"def normalize_path(path)\n  if defined?(Grape::Util::PathNormalizer)\n    Grape::Util::PathNormalizer.call(path)\n  else\n    Grape::Router.normalize_path(path) # older Grape\n  end\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not call `Grape::Router` class methods directly — go through the public `Grape::Util` helpers","When supporting multiple Grape versions, wrap internal-API calls in a version-detecting helper","After upgrades, grep your code and gems for `Router.normalize_path`"],"tags":["grape","router","deprecation","paths"],"backgroundTag":"deprecated-api-usage","analyzedSha":"22d7975629846a3c0c7bd2b34e140a7a1b4af8f6","analyzedAt":"2026-08-21T17:03:54.627Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}