Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
chore: replace substr with slice (#2738)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jan 17, 2022
1 parent e27a017 commit 4111038
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/nitro/src/rollup/plugins/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import virtual from './virtual'
const unique = (arr: any[]) => Array.from(new Set(arr))

export function middleware (getMiddleware: () => ServerMiddleware[]) {
const getImportId = p => '_' + hasha(p).substr(0, 6)
const getImportId = p => '_' + hasha(p).slice(0, 6)

let lastDump = ''

Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/runtime/app/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function renderMiddleware (req, res: ServerResponse) {
let isPayloadReq = false
if (url.startsWith(STATIC_ASSETS_BASE) && url.endsWith(PAYLOAD_JS)) {
isPayloadReq = true
url = url.substr(STATIC_ASSETS_BASE.length, url.length - STATIC_ASSETS_BASE.length - PAYLOAD_JS.length) || '/'
url = url.slice(STATIC_ASSETS_BASE.length, url.length - PAYLOAD_JS.length) || '/'
}

// Initialize ssr context
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function filesToMiddleware (files: string[], baseDir: string, basePath: string,
const route = joinURL(
basePath,
file
.substr(0, file.length - extname(file).length)
.slice(0, file.length - extname(file).length)
.replace(/\/index$/, '')
)
const handle = resolve(baseDir, file)
Expand Down
2 changes: 1 addition & 1 deletion packages/nitro/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function compileTemplate (contents: string) {
return (params: Record<string, any>) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
const val = dotProp.get(params, match)
if (!val) {
consola.warn(`cannot resolve template param '${match}' in ${contents.substr(0, 20)}`)
consola.warn(`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`)
}
return val as string || `${match}`
})
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export function hash (input: string, length = 8) {
return createHash('sha256')
.update(input)
.digest('hex')
.substr(0, length)
.slice(0, length)
}

0 comments on commit 4111038

Please sign in to comment.