mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Replace replaceSubstringAtIndex with built-in String.replace
This commit is contained in:
parent
de571c7fab
commit
ad2b7c223c
@ -4,7 +4,7 @@ import React from 'react';
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import { AclInformationText } from '../../constants/acl_information_text';
|
import { AclInformationText } from '../../constants/acl_information_text';
|
||||||
import { replaceSubstringAtIndex, sanitize, intersectLists } from '../../utils/general';
|
import { intersectLists, sanitize } from '../../utils/general';
|
||||||
import { getLangText } from '../../utils/lang';
|
import { getLangText } from '../../utils/lang';
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ let AclInformation = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<p key={title}>
|
<p key={title}>
|
||||||
<span className="info">
|
<span className="info">
|
||||||
{replaceSubstringAtIndex(info.slice(2), 's ', ' ')}
|
{info.slice(2).replace('s', '')}
|
||||||
</span>
|
</span>
|
||||||
<span className="example">
|
<span className="example">
|
||||||
{' ' + example}
|
{' ' + example}
|
||||||
|
@ -5,8 +5,6 @@ import React from 'react';
|
|||||||
import Form from '../ascribe_forms/form';
|
import Form from '../ascribe_forms/form';
|
||||||
import Property from '../ascribe_forms/property';
|
import Property from '../ascribe_forms/property';
|
||||||
|
|
||||||
import { replaceSubstringAtIndex } from '../../utils/general';
|
|
||||||
|
|
||||||
|
|
||||||
let HistoryIterator = React.createClass({
|
let HistoryIterator = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -18,7 +16,7 @@ let HistoryIterator = React.createClass({
|
|||||||
// We want to get the capturing group without the quotes,
|
// We want to get the capturing group without the quotes,
|
||||||
// which is why we access the match list at index 1 and not 0
|
// which is why we access the match list at index 1 and not 0
|
||||||
const contractName = historicalEvent[1].match(/\"(.*)\"/)[1];
|
const contractName = historicalEvent[1].match(/\"(.*)\"/)[1];
|
||||||
const historicalEventDescription = replaceSubstringAtIndex(historicalEvent[1], `"${contractName}"`, '');
|
const historicalEventDescription = historicalEvent[1].replace(`"${contractName}"`, '');
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{historicalEventDescription}
|
{historicalEventDescription}
|
||||||
|
@ -27,16 +27,6 @@ export function escapeHTML(s) {
|
|||||||
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index, int, the starting index of the substring to be replaced
|
|
||||||
* @param character, substring to be replaced
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
export function replaceSubstringAtIndex(baseString, substrToReplace, stringToBePut) {
|
|
||||||
let index = baseString.indexOf(substrToReplace);
|
|
||||||
return baseString.substr(0, index) + stringToBePut + baseString.substr(index + substrToReplace.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the user's subdomain from the browser's window.
|
* Extracts the user's subdomain from the browser's window.
|
||||||
* If no subdomain is found (for example on a naked domain), the default "www" is just assumed.
|
* If no subdomain is found (for example on a naked domain), the default "www" is just assumed.
|
||||||
|
Loading…
Reference in New Issue
Block a user