fix: keep debug map link on current frontend#414
Merged
DennisOSRM merged 2 commits intogh-pagesfrom Apr 17, 2026
Merged
Conversation
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>
There was a problem hiding this comment.
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.hrefvia theURLconstructor 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.
| 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 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 on lines
+36
to
+38
| beforeEach(() => { | ||
| jest.resetModules(); | ||
| tools = require('../src/tools'); |
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.
Summary
Closes #243.