Skip to content

Commit

Permalink
Remove unnecessary assertions (#38899)
Browse files Browse the repository at this point in the history
removed unnecessary assertions of variables to prevent misuse

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
  • Loading branch information
Yuddomack committed Jul 22, 2022
1 parent 5c8a5b6 commit d034fff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/next/shared/lib/router/router.ts
Expand Up @@ -172,7 +172,7 @@ function omit<T extends { [key: string]: any }, K extends keyof T>(
const omitted: { [key: string]: any } = {}
Object.keys(object).forEach((key) => {
if (!keys.includes(key as K)) {
omitted[key as string] = object[key]
omitted[key] = object[key]
}
})
return omitted as Omit<T, K>
Expand Down Expand Up @@ -292,16 +292,16 @@ function prepareUrlAs(router: NextRouter, url: Url, as?: Url) {
}

function resolveDynamicRoute(pathname: string, pages: string[]) {
const cleanPathname = removeTrailingSlash(denormalizePagePath(pathname!))
const cleanPathname = removeTrailingSlash(denormalizePagePath(pathname))
if (cleanPathname === '/404' || cleanPathname === '/_error') {
return pathname
}

// handle resolving href for dynamic routes
if (!pages.includes(cleanPathname!)) {
if (!pages.includes(cleanPathname)) {
// eslint-disable-next-line array-callback-return
pages.some((page) => {
if (isDynamicRoute(page) && getRouteRegex(page).re.test(cleanPathname!)) {
if (isDynamicRoute(page) && getRouteRegex(page).re.test(cleanPathname)) {
pathname = page
return true
}
Expand Down Expand Up @@ -732,7 +732,7 @@ export default class Router implements BaseRouter {
const autoExportDynamic =
isDynamicRoute(pathname) && self.__NEXT_DATA__.autoExport

this.basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''
this.basePath = process.env.__NEXT_ROUTER_BASEPATH || ''
this.sub = subscription
this.clc = null
this._wrapApp = wrapApp
Expand Down

0 comments on commit d034fff

Please sign in to comment.