mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +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 { AclInformationText } from '../../constants/acl_information_text';
|
||||
import { replaceSubstringAtIndex, sanitize, intersectLists } from '../../utils/general';
|
||||
import { intersectLists, sanitize } from '../../utils/general';
|
||||
import { getLangText } from '../../utils/lang';
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ let AclInformation = React.createClass({
|
||||
return (
|
||||
<p key={title}>
|
||||
<span className="info">
|
||||
{replaceSubstringAtIndex(info.slice(2), 's ', ' ')}
|
||||
{info.slice(2).replace('s', '')}
|
||||
</span>
|
||||
<span className="example">
|
||||
{' ' + example}
|
||||
|
@ -5,8 +5,6 @@ import React from 'react';
|
||||
import Form from '../ascribe_forms/form';
|
||||
import Property from '../ascribe_forms/property';
|
||||
|
||||
import { replaceSubstringAtIndex } from '../../utils/general';
|
||||
|
||||
|
||||
let HistoryIterator = React.createClass({
|
||||
propTypes: {
|
||||
@ -18,7 +16,7 @@ let HistoryIterator = React.createClass({
|
||||
// We want to get the capturing group without the quotes,
|
||||
// which is why we access the match list at index 1 and not 0
|
||||
const contractName = historicalEvent[1].match(/\"(.*)\"/)[1];
|
||||
const historicalEventDescription = replaceSubstringAtIndex(historicalEvent[1], `"${contractName}"`, '');
|
||||
const historicalEventDescription = historicalEvent[1].replace(`"${contractName}"`, '');
|
||||
return (
|
||||
<span>
|
||||
{historicalEventDescription}
|
||||
|
@ -27,16 +27,6 @@ export function escapeHTML(s) {
|
||||
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.
|
||||
* 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