Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide URL options for e2e blob: URL images #6765

Merged
merged 1 commit into from
May 18, 2018
Merged
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
30 changes: 18 additions & 12 deletions electron_app/src/webcontents-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ function onLinkContextMenu(ev, params) {
const url = params.linkURL || params.srcURL;

const popupMenu = new Menu();
popupMenu.append(new MenuItem({
label: url,
click() {
safeOpenURL(url);
},
}));
// No point trying to open blob: URLs in an external browser: it ain't gonna work.
if (!url.startsWith('blob:')) {
popupMenu.append(new MenuItem({
label: url,
click() {
safeOpenURL(url);
},
}));
}

if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
popupMenu.append(new MenuItem({
Expand All @@ -55,12 +58,15 @@ function onLinkContextMenu(ev, params) {
}));
}

popupMenu.append(new MenuItem({
label: 'Copy Link Address',
click() {
clipboard.writeText(url);
},
}));
// No point offerring to copy a blob: URL either
if (!url.startsWith('blob:')) {
popupMenu.append(new MenuItem({
label: 'Copy Link Address',
click() {
clipboard.writeText(url);
},
}));
}
// popup() requires an options object even for no options
popupMenu.popup({});
ev.preventDefault();
Expand Down