fix: replaced deprecated String.substr with String.slice (#3224)
This commit is contained in:
parent
41c70ae503
commit
3d6e382b58
7 changed files with 11 additions and 6 deletions
5
.changeset/eight-falcons-applaud.md
Normal file
5
.changeset/eight-falcons-applaud.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Replaced deprecated String.substr with String.slice
|
|
@ -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) => {
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue