@kubb/ast 5.14.0 → 5.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1130,9 +1130,18 @@ function rewriteNodes(nodes, rewrite) {
1130
1130
  }
1131
1131
  //#endregion
1132
1132
  //#region src/utils/refs.ts
1133
- /** Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`. */
1133
+ /**
1134
+ * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
1135
+ * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
1136
+ * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
1137
+ */
1134
1138
  function refName(ref) {
1135
- return ref.split("/").at(-1) ?? ref;
1139
+ const segment = ref.split("/").at(-1) ?? ref;
1140
+ let decoded = segment;
1141
+ try {
1142
+ decoded = decodeURIComponent(segment);
1143
+ } catch {}
1144
+ return decoded.replaceAll("~1", "/").replaceAll("~0", "~");
1136
1145
  }
1137
1146
  /**
1138
1147
  * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when