Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/DevtoolsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function urlsEqual(url1: string, url2: string): boolean {
* 1. We do not care about the protocol.
* 2. We do not care about trailing slashes.
* 3. We do not care about "www".
* 4. We ignore the hash parts.
*
* For example, if the user types "record a trace on foo.com", we would want to
* match a tab in the connected Chrome instance that is showing "www.foo.com/"
Expand All @@ -56,6 +57,13 @@ function normalizeUrl(url: string): string {
result = result.slice(4);
}

// We use target URLs to locate DevTools but those often do
// no include hash.
const hashIdx = result.lastIndexOf('#');
if (hashIdx !== -1) {
result = result.slice(0, hashIdx);
}

// Remove trailing slash
if (result.endsWith('/')) {
result = result.slice(0, -1);
Expand Down
11 changes: 11 additions & 0 deletions tests/DevtoolsUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ describe('urlsEqual', () => {
false,
);
});

it('ignores hash', () => {
assert.strictEqual(
urlsEqual('https://google.com/#', 'http://www.google.com'),
true,
);
assert.strictEqual(
urlsEqual('https://google.com/#21', 'http://www.google.com#12'),
true,
);
});
});

describe('mapIssueToMessageObject', () => {
Expand Down