summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Juan Martín Seery <me@juanm04.com> 2022-04-27 15:43:43 -0300
committerGravatar GitHub <noreply@github.com> 2022-04-27 15:43:43 -0300
commit3d6e382b583646f047836b703a867c3b29ac91b2 (patch)
treee37c12b5339946864889238d35b24ba71194ea32
parent41c70ae50359247f972833feba86698980b647a5 (diff)
downloadastro-3d6e382b583646f047836b703a867c3b29ac91b2.tar.gz
astro-3d6e382b583646f047836b703a867c3b29ac91b2.tar.zst
astro-3d6e382b583646f047836b703a867c3b29ac91b2.zip
fix: replaced deprecated String.substr with String.slice (#3224)
-rw-r--r--.changeset/eight-falcons-applaud.md5
-rw-r--r--packages/astro/src/core/routing/manifest/create.ts2
-rw-r--r--packages/astro/src/runtime/server/index.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro/compile.ts2
-rw-r--r--packages/astro/src/vite-plugin-jsx/index.ts2
-rw-r--r--packages/astro/src/vite-plugin-markdown/index.ts2
-rw-r--r--packages/astro/test/astro-css-bundling.test.js2
7 files changed, 11 insertions, 6 deletions
diff --git a/.changeset/eight-falcons-applaud.md b/.changeset/eight-falcons-applaud.md
new file mode 100644
index 000000000..5896f028d
--- /dev/null
+++ b/.changeset/eight-falcons-applaud.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Replaced deprecated String.substr with String.slice
diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts
index 9555d9753..3f29fddd3 100644
--- a/packages/astro/src/core/routing/manifest/create.ts
+++ b/packages/astro/src/core/routing/manifest/create.ts
@@ -92,7 +92,7 @@ function getGenerator(segments: RoutePart[][], addTrailingSlash: AstroConfig['tr
const template = segments
.map((segment) => {
return segment[0].spread
- ? `/:${segment[0].content.substr(3)}(.*)?`
+ ? `/:${segment[0].content.slice(3)}(.*)?`
: '/' +
segment
.map((part) => {
diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts
index 72b1d92c0..bc80e5cdb 100644
--- a/packages/astro/src/runtime/server/index.ts
+++ b/packages/astro/src/runtime/server/index.ts
@@ -367,7 +367,7 @@ export function createAstro(
// When inside of project root, remove the leading path so you are
// left with only `/src/images/tower.png`
if (resolved.startsWith(projectRoot.pathname)) {
- resolved = '/' + resolved.substr(projectRoot.pathname.length);
+ resolved = '/' + resolved.slice(projectRoot.pathname.length);
}
return resolved;
},
diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts
index afa4cd637..f17695047 100644
--- a/packages/astro/src/vite-plugin-astro/compile.ts
+++ b/packages/astro/src/vite-plugin-astro/compile.ts
@@ -43,7 +43,7 @@ async function compile(
): Promise<CompileResult> {
const filenameURL = new URL(`file://${filename}`);
const normalizedID = fileURLToPath(filenameURL);
- const pathname = filenameURL.pathname.substr(config.root.pathname.length - 1);
+ const pathname = filenameURL.pathname.slice(config.root.pathname.length - 1);
let rawCSSDeps = new Set<string>();
let cssTransformError: Error | undefined;
diff --git a/packages/astro/src/vite-plugin-jsx/index.ts b/packages/astro/src/vite-plugin-jsx/index.ts
index dee04c0b1..004ae2eee 100644
--- a/packages/astro/src/vite-plugin-jsx/index.ts
+++ b/packages/astro/src/vite-plugin-jsx/index.ts
@@ -25,7 +25,7 @@ const IMPORT_STATEMENTS: Record<string, string> = {
const PREVENT_UNUSED_IMPORTS = ';;(React,Fragment,h);';
function getEsbuildLoader(fileExt: string): string {
- return fileExt.substr(1);
+ return fileExt.slice(1);
}
function collectJSXRenderers(renderers: AstroRenderer[]): Map<string, AstroRenderer> {
diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts
index 105ff47e0..405fac742 100644
--- a/packages/astro/src/vite-plugin-markdown/index.ts
+++ b/packages/astro/src/vite-plugin-markdown/index.ts
@@ -151,7 +151,7 @@ ${setup}`.trim();
// Transform from `.astro` to valid `.ts`
let { code: tsResult } = await transform(astroResult, {
- pathname: fileUrl.pathname.substr(config.root.pathname.length - 1),
+ pathname: fileUrl.pathname.slice(config.root.pathname.length - 1),
projectRoot: config.root.toString(),
site: config.site ? new URL(config.base, config.site).toString() : undefined,
sourcefile: id,
diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js
index 7b3c70384..3170b796d 100644
--- a/packages/astro/test/astro-css-bundling.test.js
+++ b/packages/astro/test/astro-css-bundling.test.js
@@ -41,7 +41,7 @@ describe('CSS Bundling', function () {
const link = $(`link[rel="stylesheet"][href^="${href}"]`);
expect(link.length).to.be.greaterThanOrEqual(1);
const outHref = link.attr('href');
- builtCSS.add(outHref.startsWith('../') ? outHref.substr(2) : outHref);
+ builtCSS.add(outHref.startsWith('../') ? outHref.slice(2) : outHref);
}
// test 2: assert old CSS was removed