mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
chore: replace substr
with slice
(#2738)
This commit is contained in:
parent
e27a0173e8
commit
4111038aa7
@ -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 = ''
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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}`
|
||||
})
|
||||
|
@ -30,5 +30,5 @@ export function hash (input: string, length = 8) {
|
||||
return createHash('sha256')
|
||||
.update(input)
|
||||
.digest('hex')
|
||||
.substr(0, length)
|
||||
.slice(0, length)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user