feat: make the debug map link configurable per routing profile - #502
Open
DennisOSRM wants to merge 1 commit into
Open
feat: make the debug map link configurable per routing profile#502DennisOSRM wants to merge 1 commit into
DennisOSRM wants to merge 1 commit into
Conversation
The "Open in Debug Map" button always opened the bundled debug map at `debug/`, whose tile source is hardcoded to a car profile. Deployments with several profiles need one debug map per profile. Routing modes now accept an optional `debugUrl` in `OSRM_MODES`, carried through `parseModes()` and `buildServices()` onto the service descriptor. The tools control exposes it as an option with a `setDebugUrl()` setter, and the debug link is refreshed on every profile change — both from the mode selector and from a back/forward history restore. Relative URLs resolve against the frontend origin, absolute URLs are used as-is, and the `#zoom/lat/lng` hash is appended in both cases. Modes without `debugUrl` keep opening the bundled debug map. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "Open in Debug Map" tool button always opens the bundled debug map at
debug/. That page has a single hardcoded vector tile source (router.project-osrm.org/tile/v1/car/…), so it can only ever match one profile. A deployment configured with car/bike/foot modes has no way to send each mode to its own debug view.Change
Routing modes accept an optional
debugUrl:[ {"name":"car","url":"http://localhost:5000","debugUrl":"debug-car/"}, {"name":"bike","url":"http://localhost:5001","debugUrl":"https://debug.example.com/bike/"} ]src/leaflet_options.js—parseModes()preservesdebugUrlfrom the mode config (alongsidepath);buildServices()carries it onto the service descriptor.src/tools.js—debugUrlbecomes a control option (default"debug/") with asetDebugUrl()setter._openDebug()reads it and falls back to the bundled map if the URL is unparseable.src/index.js— newapplyDebugUrlForProfile(), called at startup and from both places a profile switch lands: the mode-selectorchangehandler and the back/forward history restore. Without the second call the button goes stale after a browser back.Relative URLs resolve against the frontend origin (
debug-car/under/osrm-frontend/becomes/osrm-frontend/debug-car/), absolute URLs are used as-is, and the#zoom/lat/lnghash is appended either way. A mode withoutdebugUrlkeeps opening the bundleddebug/, so existing deployments are unchanged.Works the same for non-Docker deployments, where modes are set in the inline
window.osrmConfigblock inindex.html.Tests
Three cases in
test/tools.test.js(absolute URL, relative URL under a subpath, fallback when a mode has no debug URL) and one intest/leaflet_options.test.js(debugUrlsurfaces on the service, absent when unset). Full suite: 273 passed. Lint clean.bundle.js/dist/are not rebuilt here —npm run buildalso runsscripts/replace.js, which rewrites sources in place.Follow-ups, not in this PR
debug/index.htmlcould take its tile source from a query param, which would let one deployed debug map serve every profile.buildServices()readsmode.label/mode.labelKey, butparseModes()drops those fields, so they can never arrive and labels always fall back toname. Pre-existing and unrelated.🤖 Generated with Claude Code