aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/components/TodosWebview.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/todos/components/TodosWebview.js')
-rw-r--r--src/features/todos/components/TodosWebview.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js
index 2626186e9..c612702b0 100644
--- a/src/features/todos/components/TodosWebview.js
+++ b/src/features/todos/components/TodosWebview.js
@@ -12,15 +12,19 @@ import SettingsStore from '../../../stores/SettingsStore';
12import Appear from '../../../components/ui/effects/Appear'; 12import Appear from '../../../components/ui/effects/Appear';
13import UpgradeButton from '../../../components/ui/UpgradeButton'; 13import UpgradeButton from '../../../components/ui/UpgradeButton';
14 14
15import userAgent from '../../../helpers/userAgent-helpers';
16
15// NOTE: https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url 17// NOTE: https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url
16function validURL(str) { 18function validURL(str) {
17 const pattern = new RegExp('^(https?:\\/\\/)?' // protocol 19 let url;
18 + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' // domain name 20
19 + '((\\d{1,3}\\.){3}\\d{1,3}))' // OR ip (v4) address 21 try {
20 + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' // port and path 22 url = new URL(str);
21 + '(\\?[;&a-z\\d%_.~+=-]*)?' // query string 23 } catch (_) {
22 + '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator 24 return false;
23 return !!pattern.test(str); 25 }
26
27 return url.protocol === 'http:' || url.protocol === 'https:';
24} 28}
25 29
26const messages = defineMessages({ 30const messages = defineMessages({
@@ -126,6 +130,11 @@ class TodosWebview extends Component {
126 this.node.addEventListener('mousemove', this.resizePanel.bind(this)); 130 this.node.addEventListener('mousemove', this.resizePanel.bind(this));
127 this.node.addEventListener('mouseup', this.stopResize.bind(this)); 131 this.node.addEventListener('mouseup', this.stopResize.bind(this));
128 this.node.addEventListener('mouseleave', this.stopResize.bind(this)); 132 this.node.addEventListener('mouseleave', this.stopResize.bind(this));
133
134 const webViewInstance = this;
135 this.webview.addEventListener('dom-ready', () => {
136 webViewInstance.webview.setUserAgent(userAgent(true));
137 });
129 } 138 }
130 139
131 startResize = (event) => { 140 startResize = (event) => {