@libj/make-uri
Advanced tools
Comparing version 1.1.15 to 1.2.0
export declare const isStr: (val: any) => boolean, isNum: (val: any) => boolean, isBool: (val: any) => boolean, isNull: (val: any) => boolean, isArr: (val: any) => boolean, isObj: (val: any) => boolean, isFn: (val: any) => boolean; | ||
export declare const isEnumVal: (Enum: Object, val: string | number) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isFn = exports.isObj = exports.isArr = exports.isNull = exports.isBool = exports.isNum = exports.isStr = void 0; | ||
exports.isEnumVal = exports.isFn = exports.isObj = exports.isArr = exports.isNull = exports.isBool = exports.isNum = exports.isStr = void 0; | ||
exports.isStr = function (val) { return typeof val === 'string'; }, exports.isNum = function (val) { return typeof val === 'number'; }, exports.isBool = function (val) { return typeof val === 'boolean'; }, exports.isNull = function (val) { return val === null; }, exports.isArr = function (val) { return Array.isArray(val); }, exports.isObj = function (val) { return typeof val === 'object' && !exports.isArr(val) && !exports.isNull(val); }, exports.isFn = function (val) { return typeof val === 'function'; }; | ||
exports.isEnumVal = function (Enum, val) { return (Object.values(Enum).indexOf(val) > -1); }; | ||
//# sourceMappingURL=isType.js.map |
@@ -22,3 +22,11 @@ import { LooseObject } from './common/types'; | ||
} | ||
declare type PathOpt = string | PathParams | string[]; | ||
declare type PathVariants = string | PathParams | string[]; | ||
interface PathOptOptions { | ||
trimTrial?: boolean; | ||
} | ||
interface PathOptWithOpts { | ||
path: PathVariants; | ||
opts: PathOptOptions; | ||
} | ||
declare type PathOpt = PathVariants | PathOptWithOpts; | ||
interface QueryParams { | ||
@@ -25,0 +33,0 @@ $data: LooseObject; |
@@ -134,2 +134,14 @@ "use strict"; | ||
function makePath(path) { | ||
var _a; | ||
var resPath, opts = { trimTrial: false }; | ||
if (isType_1.isObj(path) && path.path && path.opts) { | ||
(_a = path, resPath = _a.path, opts = _a.opts); | ||
resPath = makeActualPath(resPath); | ||
} | ||
else { | ||
resPath = makeActualPath(path); | ||
} | ||
return UriTemplate_1.UriTemplate.path(resPath, { trimTrail: opts.trimTrial }); | ||
} | ||
function makeActualPath(path) { | ||
var res = ''; | ||
@@ -153,3 +165,3 @@ if (isType_1.isStr(path)) { | ||
} | ||
return UriTemplate_1.UriTemplate.path(res); | ||
return res; | ||
} | ||
@@ -156,0 +168,0 @@ function makeQuery(query, _a) { |
@@ -7,3 +7,5 @@ export declare const UriTemplate: { | ||
user(val: string): string; | ||
path(val: string): string; | ||
path(val: string, { trimTrail }?: { | ||
trimTrail?: boolean; | ||
}): string; | ||
query(val: string, prefix?: boolean): string; | ||
@@ -10,0 +12,0 @@ fragment(val: string): string; |
@@ -62,5 +62,6 @@ "use strict"; | ||
}, | ||
path: function (val) { | ||
path: function (val, _a) { | ||
var trimTrail = (_a === void 0 ? { trimTrail: false } : _a).trimTrail; | ||
return produce(Tpl.PATH, { path: val }, { | ||
sanitize: /^\/+/, | ||
sanitize: trimTrail ? /^\/+|\/+$/g : /^\/+/, | ||
}); | ||
@@ -67,0 +68,0 @@ }, |
{ | ||
"dependencies": {}, | ||
"name": "@libj/make-uri", | ||
"version": "1.1.15", | ||
"version": "1.2.0", | ||
"description": "Uri builder", | ||
@@ -33,3 +33,3 @@ "author": "Sergey Poskachey <seregynp@gmail.com>", | ||
], | ||
"gitHead": "0a6a9095b97de86372fb2b30d3865fefeee26327" | ||
"gitHead": "41141b1a58ed4e0b6f9330597353efaf0c4fa4d7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42499
615