kopia lustrzana https://github.com/badgen/badgen.net
chore: bump deps & cleanup (#323)
* chore: bump dev deps * chore: bump deps * chore: cleanuppull/324/head
rodzic
d64462387a
commit
7b167a519e
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
type RouteArgs = null | {
|
||||
[key: string]: string
|
||||
}
|
||||
|
||||
function matchRoute(pattern: string, path: string): RouteArgs {
|
||||
const parsedArgs: RouteArgs = {}
|
||||
|
||||
const PATTERN_SEGMENT_REG = /\/(:)?([\w-]+)([*?+]){0,1}(?:<([^>]+)>)?/g
|
||||
const PATH_SEGMENT_REG = /\/([^/]+)/g
|
||||
|
||||
let parsedPatternSegment = PATTERN_SEGMENT_REG.exec(pattern)
|
||||
let parsedPathSegment = PATH_SEGMENT_REG.exec(path)
|
||||
|
||||
while (parsedPatternSegment !== null) {
|
||||
const [ rawPatternSegment, type, name, flag, reg ] = parsedPatternSegment
|
||||
|
||||
if (parsedPathSegment === null) {
|
||||
return flag === '?' ? parsedArgs : null
|
||||
}
|
||||
|
||||
if (flag === '+') {
|
||||
parsedArgs[name] = path.slice(parsedPathSegment.index + 1)
|
||||
return parsedArgs
|
||||
}
|
||||
|
||||
const [ rawPathSegment, value ] = parsedPathSegment
|
||||
|
||||
switch (type) {
|
||||
case undefined: // literal match
|
||||
if (rawPatternSegment !== rawPathSegment) {
|
||||
return null
|
||||
}
|
||||
break
|
||||
case ':': // named segment
|
||||
if (reg) {
|
||||
if (new RegExp(`^${reg}$`).test(value)) {
|
||||
parsedArgs[name] = value
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
parsedArgs[name] = value
|
||||
}
|
||||
}
|
||||
|
||||
parsedPatternSegment = PATTERN_SEGMENT_REG.exec(pattern)
|
||||
parsedPathSegment = PATH_SEGMENT_REG.exec(path)
|
||||
}
|
||||
|
||||
if (parsedPathSegment === null) {
|
||||
return parsedArgs
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export default matchRoute
|
|
@ -27,7 +27,7 @@ export default function serveDoc (conf: BadgenServeConfig): http.RequestListener
|
|||
function generateHelpMarkdown ({ title, help, examples, handlers }: BadgenServeConfig): string {
|
||||
const mainTitle = `# ${title} Badge`
|
||||
|
||||
const customHelp = help ?? ''
|
||||
const customHelp = help || ''
|
||||
|
||||
const exampleTitle = `## Examples`
|
||||
|
||||
|
@ -49,8 +49,6 @@ function generateHelpMarkdown ({ title, help, examples, handlers }: BadgenServeC
|
|||
return `${accu}\n\n${h4}\n\n${ul}`
|
||||
}, '')
|
||||
|
||||
console.log(categorizedExamples, examplesSection)
|
||||
|
||||
return [mainTitle, customHelp, exampleTitle, examplesSection].join('\n\n')
|
||||
}
|
||||
|
||||
|
|
Plik diff jest za duży
Load Diff
16
package.json
16
package.json
|
@ -26,15 +26,15 @@
|
|||
"@sentry/node": "^5.9.0",
|
||||
"badgen": "^3.0.1",
|
||||
"badgen-icons": "^0.12.0",
|
||||
"byte-size": "^5.0.1",
|
||||
"byte-size": "^6.2.0",
|
||||
"cheerio": "^1.0.0-rc.3",
|
||||
"chrome-webstore": "^1.2.1",
|
||||
"date-fns": "^2.6.0",
|
||||
"date-fns": "^2.8.0",
|
||||
"got": "^9.6.0",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"micro": "^9.3.4",
|
||||
"millify": "^3.1.0",
|
||||
"my-way": "^1.0.2",
|
||||
"my-way": "^2.0.0",
|
||||
"original-url": "^1.2.3",
|
||||
"react-debounce-render": "^5.0.0",
|
||||
"semver": "^6.3.0",
|
||||
|
@ -48,21 +48,21 @@
|
|||
"@types/got": "^9.6.9",
|
||||
"@types/lodash.debounce": "^4.0.6",
|
||||
"@types/micro": "^7.3.3",
|
||||
"@types/node": "^12.12.8",
|
||||
"@types/node": "^12.12.11",
|
||||
"@types/react": "^16.9.11",
|
||||
"@types/react-dom": "^16.9.4",
|
||||
"@types/semver": "^6.2.0",
|
||||
"@types/supertest": "^2.0.8",
|
||||
"@types/url-parse": "^1.4.3",
|
||||
"@typescript-eslint/eslint-plugin": "^2.7.0",
|
||||
"@typescript-eslint/parser": "^2.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.8.0",
|
||||
"@typescript-eslint/parser": "^2.8.0",
|
||||
"@zeit/next-typescript": "^1.1.1",
|
||||
"csstype": "^2.6.7",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint-plugin-react": "^7.16.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"next": "^9.0.7",
|
||||
"nodemon": "^1.19.4",
|
||||
"next": "^9.1.4",
|
||||
"nodemon": "^2.0.0",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"supertest": "^4.0.2",
|
||||
|
|
Ładowanie…
Reference in New Issue