Skip to content

Commit

Permalink
Merge pull request #96 from rtablada/hotfix-hash-urls
Browse files Browse the repository at this point in the history
Fix Hash and other URL oddities: Use URL parsing instead of bespoke regex
  • Loading branch information
NullVoxPopuli authored Jul 12, 2024
2 parents cfe2531 + dd5c760 commit 300e34c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions docs-app/tests/docs-app/errors-test.gts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ module('Errors', function (hooks) {

await settled();
assert.dom('[data-page-error]').doesNotExist();

visit(`/Runtime/docs/api-docs.md#some-hash`);

await renderSettled();
assert.dom('[data-page-error]').doesNotExist();

await settled();
assert.dom('[data-page-error]').doesNotExist();

visit(`/Runtime/docs/api-docs.md?query-param=value`);

await renderSettled();
assert.dom('[data-page-error]').doesNotExist();

await settled();
assert.dom('[data-page-error]').doesNotExist();
});
});
});
3 changes: 2 additions & 1 deletion ui/src/services/kolay/selected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export default class Selected extends Service {
get path(): string | undefined {
if (!this.router.currentURL) return firstPath;

let [path] = this.router.currentURL.split('?');
let url = new URL(this.router.currentURL, window.location.origin);
let path = url.pathname;
let result = path && path !== '/' ? path : firstPath;

return result?.replace(/\.md$/, '');
Expand Down

0 comments on commit 300e34c

Please sign in to comment.