@ng-openapi/http-resource 0.0.8 → 0.0.9-pr-14-bugfix-working-directory-2ca1c89.0

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.
Files changed (4) hide show
  1. package/index.cjs +16 -10
  2. package/index.d.ts +0 -1
  3. package/index.js +16 -10
  4. package/package.json +1 -1
package/index.cjs CHANGED
@@ -3124,6 +3124,20 @@ var safeLoad = renamed("safeLoad", "load");
3124
3124
  var safeLoadAll = renamed("safeLoadAll", "loadAll");
3125
3125
  var safeDump = renamed("safeDump", "dump");
3126
3126
 
3127
+ // ../../shared/src/utils/functions/is-url.ts
3128
+ function isUrl(input) {
3129
+ try {
3130
+ const url = new URL(input);
3131
+ return [
3132
+ "http:",
3133
+ "https:"
3134
+ ].includes(url.protocol);
3135
+ } catch {
3136
+ return false;
3137
+ }
3138
+ }
3139
+ __name(isUrl, "isUrl");
3140
+
3127
3141
  // ../../shared/src/core/swagger-parser.ts
3128
3142
  var SwaggerParser = class _SwaggerParser {
3129
3143
  static {
@@ -3143,20 +3157,12 @@ var SwaggerParser = class _SwaggerParser {
3143
3157
  return new _SwaggerParser(spec, config);
3144
3158
  }
3145
3159
  static async loadContent(pathOrUrl) {
3146
- if (_SwaggerParser.isUrl(pathOrUrl)) {
3160
+ if (isUrl(pathOrUrl)) {
3147
3161
  return await _SwaggerParser.fetchUrlContent(pathOrUrl);
3148
3162
  } else {
3149
3163
  return fs.readFileSync(pathOrUrl, "utf8");
3150
3164
  }
3151
3165
  }
3152
- static isUrl(input) {
3153
- try {
3154
- new URL(input);
3155
- return true;
3156
- } catch {
3157
- return false;
3158
- }
3159
- }
3160
3166
  static async fetchUrlContent(url) {
3161
3167
  try {
3162
3168
  const response = await fetch(url, {
@@ -3188,7 +3194,7 @@ var SwaggerParser = class _SwaggerParser {
3188
3194
  }
3189
3195
  static parseSpecContent(content, pathOrUrl) {
3190
3196
  let format;
3191
- if (_SwaggerParser.isUrl(pathOrUrl)) {
3197
+ if (isUrl(pathOrUrl)) {
3192
3198
  const urlPath = new URL(pathOrUrl).pathname.toLowerCase();
3193
3199
  if (urlPath.endsWith(".json")) {
3194
3200
  format = "json";
package/index.d.ts CHANGED
@@ -83,7 +83,6 @@ declare class SwaggerParser {
83
83
  private constructor();
84
84
  static create(swaggerPathOrUrl: string, config: GeneratorConfig): Promise<SwaggerParser>;
85
85
  private static loadContent;
86
- private static isUrl;
87
86
  private static fetchUrlContent;
88
87
  private static parseSpecContent;
89
88
  private static detectFormat;
package/index.js CHANGED
@@ -3090,6 +3090,20 @@ var safeLoad = renamed("safeLoad", "load");
3090
3090
  var safeLoadAll = renamed("safeLoadAll", "loadAll");
3091
3091
  var safeDump = renamed("safeDump", "dump");
3092
3092
 
3093
+ // ../../shared/src/utils/functions/is-url.ts
3094
+ function isUrl(input) {
3095
+ try {
3096
+ const url = new URL(input);
3097
+ return [
3098
+ "http:",
3099
+ "https:"
3100
+ ].includes(url.protocol);
3101
+ } catch {
3102
+ return false;
3103
+ }
3104
+ }
3105
+ __name(isUrl, "isUrl");
3106
+
3093
3107
  // ../../shared/src/core/swagger-parser.ts
3094
3108
  var SwaggerParser = class _SwaggerParser {
3095
3109
  static {
@@ -3109,20 +3123,12 @@ var SwaggerParser = class _SwaggerParser {
3109
3123
  return new _SwaggerParser(spec, config);
3110
3124
  }
3111
3125
  static async loadContent(pathOrUrl) {
3112
- if (_SwaggerParser.isUrl(pathOrUrl)) {
3126
+ if (isUrl(pathOrUrl)) {
3113
3127
  return await _SwaggerParser.fetchUrlContent(pathOrUrl);
3114
3128
  } else {
3115
3129
  return fs.readFileSync(pathOrUrl, "utf8");
3116
3130
  }
3117
3131
  }
3118
- static isUrl(input) {
3119
- try {
3120
- new URL(input);
3121
- return true;
3122
- } catch {
3123
- return false;
3124
- }
3125
- }
3126
3132
  static async fetchUrlContent(url) {
3127
3133
  try {
3128
3134
  const response = await fetch(url, {
@@ -3154,7 +3160,7 @@ var SwaggerParser = class _SwaggerParser {
3154
3160
  }
3155
3161
  static parseSpecContent(content, pathOrUrl) {
3156
3162
  let format;
3157
- if (_SwaggerParser.isUrl(pathOrUrl)) {
3163
+ if (isUrl(pathOrUrl)) {
3158
3164
  const urlPath = new URL(pathOrUrl).pathname.toLowerCase();
3159
3165
  if (urlPath.endsWith(".json")) {
3160
3166
  format = "json";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-openapi/http-resource",
3
- "version": "0.0.8",
3
+ "version": "0.0.9-pr-14-bugfix-working-directory-2ca1c89.0",
4
4
  "description": "HTTP Resource plugin for ng-openapi - Angular HTTP utilities with caching and state management",
5
5
  "keywords": [
6
6
  "angular",