Skip to content

Commit

Permalink
Use encodeURIComponent everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Jul 21, 2022
1 parent 1a33fb3 commit b07d948
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/background/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getSharePrice(pool) {
* @returns {Promise<Balance>}
*/
export async function getBalance(address) {
let url = "/chain/account/info/" + address;
let url = "/chain/account/info/" + encodeURIComponent(address);
let account = await commonFetch(url).catch(() => {});
if (account && account.code === 0) {
return { ...account.data, address };
Expand Down Expand Up @@ -101,7 +101,7 @@ export async function getTransactionList(address) {
*/
export async function getAccountStakeInfo(address) {
let url =
"/chain/account/delegations?address=" + address + "&size=" + MAX_LENGTH;
"/chain/account/delegations?address=" + encodeURIComponent(address) + "&size=" + encodeURIComponent(MAX_LENGTH);
let accountStakeInfo = await commonFetch(url).catch(() => []);
return accountStakeInfo;
}
Expand All @@ -112,7 +112,7 @@ export async function getAccountStakeInfo(address) {
* @returns
*/
export async function getNodeStakeInfo(address) {
let url = "/validator/info?address=" + address;
let url = "/validator/info?address=" + encodeURIComponent(address);
let validatorInfo = await commonFetch(url).catch(() => {});
return validatorInfo;
}
Expand All @@ -124,7 +124,7 @@ export async function getNodeStakeInfo(address) {
*/
export async function getUserDebondInfo(address) {
let url =
"/chain/account/debonding?address=" + address + "&size=" + MAX_LENGTH;
"/chain/account/debonding?address=" + encodeURIComponent(address) + "&size=" + encodeURIComponent(MAX_LENGTH);
let userDebondInfo = await commonFetch(url).catch(() => {});
return userDebondInfo;
}
Expand All @@ -135,7 +135,7 @@ export async function getUserDebondInfo(address) {
* @returns
*/
export async function getNodeStakeList() {
let url = "/validator/list?pageSize=" + MAX_LENGTH;
let url = "/validator/list?pageSize=" + encodeURIComponent(MAX_LENGTH);
let validatorList = await commonFetch(url).catch(() => []);
return validatorList;
}
Expand All @@ -146,7 +146,7 @@ export async function getNodeStakeList() {
* @returns
*/
export async function getSubmitStatus(txhash) {
let url = "/chain/transaction/" + txhash;
let url = "/chain/transaction/" + encodeURIComponent(txhash);
let txStatus = await commonFetch(url).catch(() => {});
if (txStatus && txStatus.code === 0) {
return txStatus.data;
Expand Down Expand Up @@ -202,7 +202,7 @@ export async function getRpcRuntimeList() {
* @returns
*/
export async function getRuntimeTxDetail(txhash, runtimeId) {
let url = `/runtime/transaction/info?id=${runtimeId}&hash=${txhash}`;
let url = `/runtime/transaction/info?id=${encodeURIComponent(runtimeId)}&hash=${encodeURIComponent(txhash)}`;
let txDetail = await commonFetch(url).catch(() => {});
if (txDetail && txDetail.code === 0) {
return txDetail.data;
Expand Down
2 changes: 1 addition & 1 deletion src/background/service/APIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ class APIService {
}
}
notification = (hash,runtimeId) => {
let notifyId = runtimeId ? hash +"?runtime="+runtimeId : hash
let notifyId = runtimeId ? encodeURIComponent(hash) +"?runtime="+encodeURIComponent(runtimeId) : encodeURIComponent(hash)
let myNotificationID
extension.notifications &&
extension.notifications.onClicked.addListener(function (clickId) {
Expand Down
4 changes: 2 additions & 2 deletions src/popup/pages/Record/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class Record extends React.Component {
let hash = this.state.txDetail.txHash || this.state.txDetail.hash
let url
if (this.state.isEvmTx) {
url = getExplorerUrl() + "paratimes/transactions/" + hash + "?runtime=" + this.state.txDetail.runtimeId
url = getExplorerUrl() + "paratimes/transactions/" + encodeURIComponent(hash) + "?runtime=" + encodeURIComponent(this.state.txDetail.runtimeId)
} else {
url = getExplorerUrl() + "transactions/" + hash
url = getExplorerUrl() + "transactions/" + encodeURIComponent(hash)
}
openTab(url)
}
Expand Down
2 changes: 1 addition & 1 deletion src/popup/pages/Wallet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class Wallet extends React.Component {
return className
}
onClickGoExplorer = () => {
let url = getExplorerUrl() + "accounts/detail/" + this.props.currentAccount.address
let url = getExplorerUrl() + "accounts/detail/" + encodeURIComponent(this.props.currentAccount.address)
openTab(url)
}
renderListExplorer = (index) => {
Expand Down

0 comments on commit b07d948

Please sign in to comment.