Skip to content

fix: keep debug map link on current frontend#414

Merged
DennisOSRM merged 2 commits intogh-pagesfrom
fix/debug-map-local-link
Apr 17, 2026
Merged

fix: keep debug map link on current frontend#414
DennisOSRM merged 2 commits intogh-pagesfrom
fix/debug-map-local-link

Conversation

@DennisOSRM
Copy link
Copy Markdown
Contributor

Summary

  • build the debug map URL from the current page URL
  • keep debug map links working for root and subpath-hosted frontends
  • add regression coverage for the debug map link behavior

Closes #243.

Use the current page URL to build the debug viewer link so self-hosted and subpath deployments open their own /debug route instead of resolving elsewhere.

Add regression coverage for root and subpath-hosted frontends.

Closes #243.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 09:46
@DennisOSRM DennisOSRM enabled auto-merge (squash) April 17, 2026 09:50
@DennisOSRM DennisOSRM disabled auto-merge April 17, 2026 09:50
@DennisOSRM DennisOSRM merged commit d25b9d9 into gh-pages Apr 17, 2026
5 checks passed
@DennisOSRM DennisOSRM deleted the fix/debug-map-local-link branch April 17, 2026 09:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the debug map link generation to always target the current frontend URL (including subpath deployments) and adds Jest regression tests to validate the behavior.

Changes:

  • Build the debug map URL using window.location.href via the URL constructor to preserve the current frontend base.
  • Update _openDebug() to open an absolute debug URL with the correct hash fragment.
  • Add Jest (jsdom) regression tests covering root and subpath-hosted frontends.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/tools.js Reworks _openDebug() to construct the debug URL from the current page URL.
test/tools.test.js Adds regression tests asserting the debug link targets the correct origin/subpath.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tools.js
prec = 6,
debugUrl = new URL('debug/', window.location.href);
debugUrl.hash = zoom + "/" + position.lat.toFixed(prec) + "/" + position.lng.toFixed(prec);
window.open(debugUrl.href);
Comment thread test/tools.test.js
Comment on lines +55 to +73
test('opens the debug map on the current frontend origin', () => {
window.history.replaceState({}, '', '/?z=13');

control._openDebug();

expect(openSpy).toHaveBeenCalledWith(
'http://localhost/debug/#13/38.899500/-77.026900'
);
});

test('preserves a frontend subpath when opening the debug map', () => {
window.history.replaceState({}, '', '/osrm-frontend/index.html?z=13');

control._openDebug();

expect(openSpy).toHaveBeenCalledWith(
'http://localhost/osrm-frontend/debug/#13/38.899500/-77.026900'
);
});
Comment thread test/tools.test.js
Comment on lines +36 to +38
beforeEach(() => {
jest.resetModules();
tools = require('../src/tools');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Open in debug map" redirecting to map.project-osrm.org

2 participants