MCPcopy Create free account
hub / github.com/apache/camel-website / versionlessRedirects

Function versionlessRedirects

gulpfile.js:97–114  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

95
96const REDIRECT_RX = /^Redirect 302 \/(?<component>c.*)\/latest \/\k<component>\/(?<version>.*)$/
97
98function versionlessRedirects (text) {
99 const lines = text.split('\n')
100 const processed = lines.reduce((accum, line) => {
101 accum.push(line)
102 const m = line.match(REDIRECT_RX)
103 if (m) {
104 accum.push(`RedirectMatch 302 "^/${m.groups.component}(/?)$" "/${m.groups.component}/${m.groups.version}/"`)
105 // The first line redirects **/next to **/next/ so the second line does not match.
106 // Apparently it needs to be a match or it will transform **/next/ to **/next//
107 accum.push(`RedirectMatch 301 "^/${m.groups.component}/next$" "/${m.groups.component}/next/"`)
108 accum.push(`RedirectMatch 302 "^/${m.groups.component}/(?![0-9].*|next/)(.+)$" "/${m.groups.component}/${m.groups.version}/$1"`)
109 // As an alternative, the following line works as long as no file names start with 'next'
110 // accum.push(`RedirectMatch 302 "^/${m.groups.component}/(?![0-9].*|next)(.+)$" "/${m.groups.component}/${m.groups.version}/$1"`)
111 }
112 return accum
113 }, [])
114 return processed.join('\n')
115}
116
117// Register the generate-markdown task with lazy loading to avoid requiring

Callers 1

gulpfile.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected