Repository: nuxt/nuxt
File: packages/nuxt/src/pages/utils.ts (TypeScript)

Code before:
      }

      for (const property of pageMetaArgument.properties) {
        if (property.type !== 'Property') {
          continue
        }
        const isIdentifierOrLiteral = property.key.type === 'Literal' || property.key.type === 'Identifier'
        if (!isIdentifierOrLiteral) {
          continue
        }
        const name = property.key.type === 'Identifier' ? property.key.name : String(property.value)
        if (!extractionKeys.has(name as keyof NuxtPage)) {
          dynamicProperties.add('meta')
          break
        }
      }

      if (dynamicProperties.size) {
        extractedMeta.meta ??= {}
        extractedMeta.meta[DYNAMIC_META_KEY] = dynamicProperties
      }
    })
  }

  metaCache[cacheKey] = extractedMeta
  return extractedMeta
}

const COLON_RE = /:/g
function getRoutePath (tokens: SegmentToken[]): string {
  return tokens.reduce((path, token) => {
    return (
      path +
      (token.type === SegmentTokenType.optional
        ? `:${token.value}?`
        : token.type === SegmentTokenType.dynamic
          ? `:${token.value}()`
          : token.type === SegmentTokenType.catchall
            ? `:${token.value}(.*)*`
            : token.type === SegmentTokenType.group
              ? ''
              : encodePath(token.value).replace(COLON_RE, '\\:'))
    )
  }, '/')
}

const PARAM_CHAR_RE = /[\w.]/

function parseSegment (segment: string, absolutePath: string) {
  let state: SegmentParserState = SegmentParserState.initial
  let i = 0

Review comment (refactor):
would it resolve it just to do something like:

```suggestion
  return JSON.parse(JSON.stringify(extractedMeta))
```

Code after:
      for (const property of pageMetaArgument.properties) {
        if (property.type !== 'Property') {
          continue
        }
        const isIdentifierOrLiteral = property.key.type === 'Literal' || property.key.type === 'Identifier'
        if (!isIdentifierOrLiteral) {
          continue
        }
        const name = property.key.type === 'Identifier' ? property.key.name : String(property.value)
        if (!extractionKeys.has(name as keyof NuxtPage)) {
          dynamicProperties.add('meta')
          break
        }
      }

      if (dynamicProperties.size) {
        extractedMeta.meta ??= {}
        extractedMeta.meta[DYNAMIC_META_KEY] = dynamicProperties
      }
    })
  }

  metaCache[absolutePath] = extractedMeta
  return klona(extractedMeta)
}

const COLON_RE = /:/g
function getRoutePath (tokens: SegmentToken[]): string {
  return tokens.reduce((path, token) => {
    return (
      path +
      (token.type === SegmentTokenType.optional
        ? `:${token.value}?`
        : token.type === SegmentTokenType.dynamic
          ? `:${token.value}()`
          : token.type === SegmentTokenType.catchall
            ? `:${token.value}(.*)*`
            : token.type === SegmentTokenType.group
              ? ''
              : encodePath(token.value).replace(COLON_RE, '\\:'))
    )
  }, '/')
}

const PARAM_CHAR_RE = /[\w.]/

function parseSegment (segment: string, absolutePath: string) {
  let state: SegmentParserState = SegmentParserState.initial
  let i = 0

  let buffer = ''