diff --git a/app/assets/v2/js/base.js b/app/assets/v2/js/base.js index b7d856577e8..210dd45dc91 100644 --- a/app/assets/v2/js/base.js +++ b/app/assets/v2/js/base.js @@ -64,8 +64,10 @@ document.addEventListener('DOMContentLoaded', function() { } var force_no_www = function() { - if (document.location.href.indexOf('https://www.gitcoin.co') != -1) { - var new_url = document.location.href.replace('www.gitcoin.co', 'gitcoin.co'); + const url = new URL(document.location.href); + + if (url.host == 'www.gitcoin.co') { + const new_url = document.location.href.replace('www.gitcoin.co', 'gitcoin.co'); document.location.href = new_url; } diff --git a/app/assets/v2/js/pages/hackathon_new_bounty.js b/app/assets/v2/js/pages/hackathon_new_bounty.js index 110f19a6aa0..ef08a290076 100644 --- a/app/assets/v2/js/pages/hackathon_new_bounty.js +++ b/app/assets/v2/js/pages/hackathon_new_bounty.js @@ -17,14 +17,14 @@ Vue.mixin({ return vm.form.issueDetails; } - if (url.indexOf('github.com/') < 0) { + const ghIssueUrl = new URL(url); + + if (ghIssueUrl.host == 'github.com') { vm.form.issueDetails = null; vm.$set(vm.errors, 'issueDetails', 'Please paste a github issue url'); return; } - let ghIssueUrl = new URL(url); - vm.orgSelected = ''; const apiUrldetails = `/sync/get_issue_details?url=${encodeURIComponent(url.trim())}&hackathon_slug=${vm.hackathonSlug}`; diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index 576307aceeb..89a99c6efc4 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -22,18 +22,19 @@ Vue.mixin({ return vm.form.issueDetails; } - if (url.indexOf('github.com/') < 0) { + const ghIssueUrl = new URL(url); + + if (ghIssueUrl.host == 'github.com') { vm.form.issueDetails = undefined; vm.$set(vm.errors, 'issueDetails', 'Please paste a github issue url'); return; } - if (url.indexOf('/pull/') > 0) { + if (ghIssueUrl.pathname.contains('/pull/')) { vm.$set(vm.errors, 'issueDetails', 'Please paste a github issue url and not a PR'); return; } - let ghIssueUrl = new URL(url); vm.orgSelected = ghIssueUrl.pathname.split('/')[1].toLowerCase(); diff --git a/app/assets/v2/js/users-elastic.js b/app/assets/v2/js/users-elastic.js index 893a9f15aa8..f70d350cf64 100644 --- a/app/assets/v2/js/users-elastic.js +++ b/app/assets/v2/js/users-elastic.js @@ -174,7 +174,8 @@ Vue.mixin({ vm.errorIssueDetails = undefined; - if (url.indexOf('github.com/') < 0) { + url = new URL(url); + if (url.host == 'github.com') { vm.issueDetails = null; vm.errorIssueDetails = 'Please paste a github issue url'; return; diff --git a/app/assets/v2/js/users.js b/app/assets/v2/js/users.js index 9dc702defd8..d2ee0952b82 100644 --- a/app/assets/v2/js/users.js +++ b/app/assets/v2/js/users.js @@ -175,11 +175,12 @@ Vue.mixin({ vm.errorIssueDetails = undefined; - if (url.indexOf('github.com/') < 0) { + if (new URL(url).host == 'github.com') { vm.issueDetails = null; vm.errorIssueDetails = 'Please paste a github issue url'; return; } + vm.issueDetails = undefined; const getIssue = fetchData(apiUrldetails, 'GET'); diff --git a/app/assets/v2/js/wallet.js b/app/assets/v2/js/wallet.js index 39d7af1674b..87644da44ec 100644 --- a/app/assets/v2/js/wallet.js +++ b/app/assets/v2/js/wallet.js @@ -22,7 +22,8 @@ if (window.ethereum) { function initWallet() { // Determine if we're on prod or not - const isProd = document.location.href.startsWith('https://gitcoin.co'); + const url = new URL(document.location.href); + const isProd = url.host == 'gitcoin.co' && url.protocol == 'https:'; const formaticKey = isProd ? document.contxt['fortmatic_live_key'] : document.contxt['fortmatic_test_key']; const providerOptions = { authereum: { diff --git a/app/dashboard/templates/addinterest.html b/app/dashboard/templates/addinterest.html index 4f97e123849..8cc1a244d6f 100644 --- a/app/dashboard/templates/addinterest.html +++ b/app/dashboard/templates/addinterest.html @@ -98,7 +98,11 @@