(req)
| 168 | } |
| 169 | |
| 170 | function usePermanentRedirect(req) { |
| 171 | // If the redirect was to essentially swap `enterprise-server@latest` |
| 172 | // for `enterprise-server@3.x` then, we definitely don't want to |
| 173 | // do a permanent redirect. |
| 174 | // When this is the case, we don't want a permanent redirect because |
| 175 | // it could overzealously cache in the users' browser which could |
| 176 | // be bad when whatever "latest" means changes. |
| 177 | if (req.path.includes('/enterprise-server@latest')) return false |
| 178 | |
| 179 | // If the redirect involved injecting a language prefix, then don't |
| 180 | // permanently redirect because that could overly cache in users' |
| 181 | // browsers if we some day want to make the language redirect |
| 182 | // depend on a cookie or 'Accept-Language' header. |
| 183 | if (pathLanguagePrefixed(req.path)) return true |
| 184 | |
| 185 | // The default is to *not* do a permanent redirect. |
| 186 | return false |
| 187 | } |
| 188 | |
| 189 | function removeQueryParams(redirect) { |
| 190 | return new URL(redirect, 'https://docs.github.com').pathname |
no test coverage detected