Skip to content

Commit

Permalink
feat: rewrite utils to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
Geminii committed Jan 23, 2021
1 parent 1ae13a3 commit ba93d24
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { posix as path } from 'path'
import { NuxtOptions } from '@nuxt/types'

export function joinUrl (...args: string[]) {
return path.join(...args).replace(':/', '://')
}

export function isUrl (url: string) {
return url.indexOf('http') === 0 || url.indexOf('//') === 0
}

export function getRouteParams (options: NuxtOptions) {
// routerBase
const routerBase = options.router.base

// publicPath
let publicPath
if (isUrl(options.build.publicPath)) {
publicPath = options.build.publicPath
} else {
publicPath = joinUrl(routerBase, options.build.publicPath)
}

return {
routerBase,
publicPath
}
}

module.exports = {
joinUrl,
getRouteParams
}

0 comments on commit ba93d24

Please sign in to comment.