Replace deprecated String.prototype.substr()
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
This commit is contained in:
parent
3a8cc2d4d5
commit
d20d7734cd
@ -146,7 +146,7 @@ function buildAppleAssociatedAppsFile(clients) {
|
|||||||
async function buildCss(entryPath, targetDir, assets) {
|
async function buildCss(entryPath, targetDir, assets) {
|
||||||
entryPath = path.join(projectDir, entryPath);
|
entryPath = path.join(projectDir, entryPath);
|
||||||
const assetUrlMapper = ({absolutePath}) => {
|
const assetUrlMapper = ({absolutePath}) => {
|
||||||
const relPath = absolutePath.substr(projectDir.length);
|
const relPath = absolutePath.slice(projectDir.length);
|
||||||
return assets.resolve(path.join(targetDir, relPath));
|
return assets.resolve(path.join(targetDir, relPath));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ class AssetMap {
|
|||||||
if (!resourcePath.startsWith(this._targetDir)) {
|
if (!resourcePath.startsWith(this._targetDir)) {
|
||||||
throw new Error(`absolute path ${resourcePath} that is not within target dir ${this._targetDir}`);
|
throw new Error(`absolute path ${resourcePath} that is not within target dir ${this._targetDir}`);
|
||||||
}
|
}
|
||||||
relPath = resourcePath.substr(this._targetDir.length + 1); // + 1 for the /
|
relPath = resourcePath.slice(this._targetDir.length + 1); // + 1 for the /
|
||||||
}
|
}
|
||||||
return relPath;
|
return relPath;
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ class AssetMap {
|
|||||||
if (!assetMap.directory.startsWith(this.directory)) {
|
if (!assetMap.directory.startsWith(this.directory)) {
|
||||||
throw new Error(`map directory doesn't start with this directory: ${assetMap.directory} ${this.directory}`);
|
throw new Error(`map directory doesn't start with this directory: ${assetMap.directory} ${this.directory}`);
|
||||||
}
|
}
|
||||||
const relSubRoot = assetMap.directory.substr(this.directory.length + 1);
|
const relSubRoot = assetMap.directory.slice(this.directory.length + 1);
|
||||||
for (const [key, value] of assetMap._assets.entries()) {
|
for (const [key, value] of assetMap._assets.entries()) {
|
||||||
this._assets.set(path.join(relSubRoot, key), path.join(relSubRoot, value));
|
this._assets.set(path.join(relSubRoot, key), path.join(relSubRoot, value));
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ function getWebInstanceMap(queryParams) {
|
|||||||
const postfix = "]";
|
const postfix = "]";
|
||||||
const webInstanceParams = queryParams.filter(([key]) => key.startsWith(prefix) && key.endsWith(postfix));
|
const webInstanceParams = queryParams.filter(([key]) => key.startsWith(prefix) && key.endsWith(postfix));
|
||||||
const webInstances = webInstanceParams.map(([key, value]) => {
|
const webInstances = webInstanceParams.map(([key, value]) => {
|
||||||
const noPrefix = key.substr(prefix.length);
|
const noPrefix = key.slice(prefix.length);
|
||||||
const clientId = noPrefix.substr(0, noPrefix.length - postfix.length);
|
const clientId = noPrefix.slice(0, -postfix.length);
|
||||||
return [clientId, value];
|
return [clientId, value];
|
||||||
});
|
});
|
||||||
return webInstances.reduce((map, [clientId, host]) => {
|
return webInstances.reduce((map, [clientId, host]) => {
|
||||||
@ -110,7 +110,7 @@ export class Link {
|
|||||||
if (!linkStr.startsWith("#/")) {
|
if (!linkStr.startsWith("#/")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
linkStr = linkStr.substr(2);
|
linkStr = linkStr.slice(2);
|
||||||
const [identifier, eventId] = linkStr.split("/");
|
const [identifier, eventId] = linkStr.split("/");
|
||||||
|
|
||||||
let viaServers = [];
|
let viaServers = [];
|
||||||
|
@ -66,7 +66,7 @@ export class RootViewModel extends ViewModel {
|
|||||||
this.createLinkViewModel = null;
|
this.createLinkViewModel = null;
|
||||||
let newLink;
|
let newLink;
|
||||||
if (hash.startsWith("#/policy/")) {
|
if (hash.startsWith("#/policy/")) {
|
||||||
const server = hash.substr(9);
|
const server = hash.slice(9);
|
||||||
this._updateChildVMs(null, oldLink);
|
this._updateChildVMs(null, oldLink);
|
||||||
this.loadServerPolicyViewModel = new LoadServerPolicyViewModel(this.childOptions({server}));
|
this.loadServerPolicyViewModel = new LoadServerPolicyViewModel(this.childOptions({server}));
|
||||||
this.loadServerPolicyViewModel.load();
|
this.loadServerPolicyViewModel.load();
|
||||||
|
@ -139,7 +139,7 @@ export class ClientViewModel extends ViewModel {
|
|||||||
let label = preferredWebInstance;
|
let label = preferredWebInstance;
|
||||||
const subDomainIdx = preferredWebInstance.lastIndexOf(".", preferredWebInstance.lastIndexOf("."));
|
const subDomainIdx = preferredWebInstance.lastIndexOf(".", preferredWebInstance.lastIndexOf("."));
|
||||||
if (subDomainIdx !== -1) {
|
if (subDomainIdx !== -1) {
|
||||||
label = preferredWebInstance.substr(preferredWebInstance.length - subDomainIdx + 1);
|
label = preferredWebInstance.slice(preferredWebInstance.length - subDomainIdx + 1);
|
||||||
}
|
}
|
||||||
return `Hosted by ${label}`;
|
return `Hosted by ${label}`;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function noTrailingSlash(url) {
|
function noTrailingSlash(url) {
|
||||||
return url.endsWith("/") ? url.substr(0, url.length - 1) : url;
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolveServer(request, baseURL) {
|
export async function resolveServer(request, baseURL) {
|
||||||
@ -123,7 +123,7 @@ export class HomeServer {
|
|||||||
function parseMxcUrl(url) {
|
function parseMxcUrl(url) {
|
||||||
const prefix = "mxc://";
|
const prefix = "mxc://";
|
||||||
if (url.startsWith(prefix)) {
|
if (url.startsWith(prefix)) {
|
||||||
return url.substr(prefix.length).split("/", 2);
|
return url.slice(prefix.length).split("/", 2);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ class TemplateBuilder {
|
|||||||
setAttribute(node, key, classNames(value));
|
setAttribute(node, key, classNames(value));
|
||||||
}
|
}
|
||||||
} else if (key.startsWith("on") && key.length > 2 && isFn) {
|
} else if (key.startsWith("on") && key.length > 2 && isFn) {
|
||||||
const eventName = key.substr(2, 1).toLowerCase() + key.substr(3);
|
const eventName = key.slice(2, 3).toLowerCase() + key.slice(3);
|
||||||
const handler = value;
|
const handler = value;
|
||||||
this._templateView._addEventListener(node, eventName, handler);
|
this._templateView._addEventListener(node, eventName, handler);
|
||||||
} else if (isFn) {
|
} else if (isFn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user