summaryrefslogtreecommitdiff
path: root/source/features/faster-pr-diff-options.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'source/features/faster-pr-diff-options.tsx')
-rw-r--r--source/features/faster-pr-diff-options.tsx16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/features/faster-pr-diff-options.tsx b/source/features/faster-pr-diff-options.tsx
index 287247ed..871d19a6 100644
--- a/source/features/faster-pr-diff-options.tsx
+++ b/source/features/faster-pr-diff-options.tsx
@@ -6,19 +6,19 @@ import {BookIcon, CheckIcon, DiffIcon} from '@primer/octicons-react';
import features from '.';
function createDiffStyleToggle(): DocumentFragment {
- const parameters = new URLSearchParams(location.search);
+ const url = new URL(location.href);
const isUnified = select.exists([
'[value="unified"][checked]', // Form in PR
'.table-of-contents .selected[href$=unified]' // Link in single commit
]);
function makeLink(type: string, icon: Element, selected: boolean): HTMLElement {
- parameters.set('diff', type);
+ url.searchParams.set('diff', type);
return (
<a
className={`btn btn-sm BtnGroup-item tooltipped tooltipped-s ${selected ? 'selected' : ''}`}
aria-label={`Show ${type} diffs`}
- href={`?${String(parameters)}`}
+ href={url.href}
>
{icon}
</a>
@@ -34,18 +34,18 @@ function createDiffStyleToggle(): DocumentFragment {
}
function createWhitespaceButton(): HTMLElement {
- const searchParameters = new URLSearchParams(location.search);
- const isHidingWhitespace = searchParameters.get('w') === '1';
+ const url = new URL(location.href);
+ const isHidingWhitespace = url.searchParams.get('w') === '1';
if (isHidingWhitespace) {
- searchParameters.delete('w');
+ url.searchParams.delete('w');
} else {
- searchParameters.set('w', '1');
+ url.searchParams.set('w', '1');
}
return (
<a
- href={`?${String(searchParameters)}`}
+ href={url.href}
data-hotkey="d w"
className={`btn btn-sm btn-outline tooltipped tooltipped-s ${isHidingWhitespace ? 'bg-gray-light text-gray-light color-text-tertiary' : ''}`}
aria-label={`${isHidingWhitespace ? 'Show' : 'Hide'} whitespace in diffs`}