aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/Link.js
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-14 14:52:24 +0000
committerLibravatar GitHub <noreply@github.com>2021-08-14 20:22:24 +0530
commit8a37b92bc83db229a788008c5a6a68cf51216ed2 (patch)
tree1929798a3aa4089203668bd2b93dba497363eb5a /src/components/ui/Link.js
parentNew Crowdin updates (#1786) (diff)
downloadferdium-app-8a37b92bc83db229a788008c5a6a68cf51216ed2.tar.gz
ferdium-app-8a37b92bc83db229a788008c5a6a68cf51216ed2.tar.zst
ferdium-app-8a37b92bc83db229a788008c5a6a68cf51216ed2.zip
Refactoring: Url helpers (#1789)
These changes are mainly to ensure that 'shell.open*' invocations are only in a single file. * Moved 'openPath' into the 'url-helpers' file. * Extract 'openExternalUrl' into a common location in 'url-helpers' This is done so that we can then apply vetting rules to ensure that there is no security concern as described in https://benjamin-altpeter.de/shell-openexternal-dangers/
Diffstat (limited to 'src/components/ui/Link.js')
-rw-r--r--src/components/ui/Link.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/components/ui/Link.js b/src/components/ui/Link.js
index fd14b7018..003211e5c 100644
--- a/src/components/ui/Link.js
+++ b/src/components/ui/Link.js
@@ -1,4 +1,3 @@
1import { shell } from 'electron';
2import React, { Component } from 'react'; 1import React, { Component } from 'react';
3import PropTypes from 'prop-types'; 2import PropTypes from 'prop-types';
4import { inject, observer } from 'mobx-react'; 3import { inject, observer } from 'mobx-react';
@@ -7,15 +6,18 @@ import classnames from 'classnames';
7 6
8import { oneOrManyChildElements } from '../../prop-types'; 7import { oneOrManyChildElements } from '../../prop-types';
9import { matchRoute } from '../../helpers/routing-helpers'; 8import { matchRoute } from '../../helpers/routing-helpers';
9import { openExternalUrl } from '../../helpers/url-helpers';
10 10
11// TODO: create container component for this component 11// TODO: create container component for this component
12export default @inject('stores') @observer class Link extends Component { 12export default @inject('stores') @observer class Link extends Component {
13 onClick(e) { 13 onClick(e) {
14 if (this.props.disabled) e.preventDefault(); 14 if (this.props.disabled) {
15 else if (this.props.target === '_blank') {
16 e.preventDefault(); 15 e.preventDefault();
17 shell.openExternal(this.props.to); 16 } else if (this.props.target === '_blank') {
17 e.preventDefault();
18 openExternalUrl(this.props.to, true);
18 } 19 }
20 // Note: if neither of the above, then let the other onClick handlers process it
19 } 21 }
20 22
21 render() { 23 render() {