UNPKG

dtsgeneratorws

Version:

TypeScript d.ts file generator for JSON Schema file

51 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var url = tslib_1.__importStar(require("url")); var SchemaId = (function () { function SchemaId(inputId, parentIds) { this.inputId = inputId; var absoluteId = url.resolve('', inputId); if (parentIds) { parentIds.forEach(function (parent) { if (parent) { absoluteId = url.resolve(parent, absoluteId); } }); } if (absoluteId.indexOf('#') < 0) { absoluteId += '#'; } if (absoluteId.indexOf('://') < 0 && absoluteId[0] !== '/' && absoluteId[0] !== '#') { absoluteId = '/' + absoluteId; } this.id = url.parse(absoluteId); this.absoluteId = this.id.href; } SchemaId.prototype.getAbsoluteId = function () { return this.absoluteId; }; SchemaId.prototype.isEmpty = function () { return !!this.absoluteId; }; SchemaId.prototype.isFetchable = function () { return /https?\:\/\//.test(this.absoluteId); }; SchemaId.prototype.getFileId = function () { return this.absoluteId.replace(/#.*$/, '#'); }; SchemaId.prototype.existsJsonPointerHash = function () { return this.absoluteId === '#' || /#\//.test(this.absoluteId); }; SchemaId.prototype.getJsonPointerHash = function () { var m = /(#\/.*)$/.exec(this.absoluteId); if (m == null) { return '#'; } return decodeURIComponent(m[1]); }; SchemaId.empty = new SchemaId(''); return SchemaId; }()); exports.default = SchemaId; //# sourceMappingURL=schemaId.js.map