MCPcopy Index your code
hub / github.com/refined-github/refined-github / getFilenames

Function getFilenames

source/features/restore-file.tsx:100–120  ·  view source on GitHub ↗
(menuItem: HTMLElement)

Source from the content-addressed store, hash-verified

98}
99
100function getFilenames(menuItem: HTMLElement): {original: string; new: string} {
101 // Legacy view: get filenames from the data-path and Link--primary elements
102 if (menuItem.tagName === 'BUTTON') {
103 const [originalFileName, newFileName = originalFileName] = $(
104 '.Link--primary',
105 closestElement('[data-path]', menuItem),
106 )
107 .textContent
108 .split(' → ');
109
110 return {original: originalFileName, new: newFileName};
111 }
112
113 // New React view: get filenames from the file header
114 const fileNameElement = $('[class^="DiffFileHeader-module__file-name"]', focusedFileContainer);
115 const span = $optional('span:not(.sr-only)', fileNameElement);
116 const [originalFileName, newFileName = originalFileName] = (span ?? fileNameElement)
117 .textContent.split(' ').map(text => text.replaceAll('\u{200E}', ''));
118
119 return {original: originalFileName, new: newFileName};
120}
121
122async function handleClick(event: DelegateEvent<MouseEvent, HTMLButtonElement>): Promise<void> {
123 const menuItem = event.delegateTarget;

Callers 1

handleClickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected