Skip to content

Commit

Permalink
[testharness.js] Fix issue caused when path contains full stop charac…
Browse files Browse the repository at this point in the history
…ters (.)

web-platform-tests#50693

The current implementation of `get_title()` assumes that the path does not contain a full stop character.
If it does, `get_title()` would return parts of the path, in stead of the filename.
The pathname `/a.path/filename.html` would cause `get_title()` to return `.path` instead of the expected `filename`.

This change fixed the issue by trimming the path away before searching for the extension.
It maintains the current behavior, where it only keeps the first part of the filename if the filename contains multiple full stop characters.
`/path/filename.foo.html` still returns `filename`.
  • Loading branch information
johannesodland committed Feb 13, 2025
1 parent c9e46c0 commit cc560cc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -4788,7 +4788,8 @@
return META_TITLE;
}
if ('location' in global_scope && 'pathname' in location) {
return location.pathname.substring(location.pathname.lastIndexOf('/') + 1, location.pathname.indexOf('.'));
var filename = location.pathname.substring(location.pathname.lastIndexOf('/') + 1)
return filename.substring(0, filename.indexOf('.'));
}
return "Untitled";
}
Expand Down

0 comments on commit cc560cc

Please sign in to comment.