url-transformers
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"scripts": { | ||
@@ -12,0 +12,0 @@ "compile": "rm -rf ./target/ && tsc", |
@@ -8,2 +8,3 @@ # `url-transformers` | ||
- `addQueryToUrl` | ||
- `replaceQueryInUrl` | ||
- `replacePathInUrl` | ||
@@ -10,0 +11,0 @@ - `replacePathnameInUrl` |
@@ -9,2 +9,7 @@ declare type ParsedUrlQueryInput = { | ||
}) => string; | ||
export declare const replaceQueryInUrl: (b: { | ||
url: string; | ||
}) => (a: { | ||
newQuery: ParsedUrlQueryInput; | ||
}) => string; | ||
export declare const replacePathInUrl: (b: { | ||
@@ -11,0 +16,0 @@ url: string; |
@@ -43,3 +43,3 @@ "use strict"; | ||
var newQuery = __assign({}, existingQuery, queryToAppend); | ||
var newParsedUrl = { | ||
return { | ||
auth: auth, | ||
@@ -52,6 +52,21 @@ protocol: protocol, | ||
}; | ||
return newParsedUrl; | ||
}; | ||
}; | ||
exports.addQueryToUrl = other_1.flipCurried(pipe_1.pipe(addQueryToParsedUrl, mapUrlWithParsedQuery)); | ||
var replaceQueryInParsedUrl = function (_a) { | ||
var newQuery = _a.newQuery; | ||
return function (_a) { | ||
var parsedUrl = _a.parsedUrl; | ||
var auth = parsedUrl.auth, protocol = parsedUrl.protocol, host = parsedUrl.host, hash = parsedUrl.hash, pathname = parsedUrl.pathname; | ||
return { | ||
auth: auth, | ||
protocol: protocol, | ||
host: host, | ||
hash: hash, | ||
pathname: pathname, | ||
query: newQuery, | ||
}; | ||
}; | ||
}; | ||
exports.replaceQueryInUrl = other_1.flipCurried(pipe_1.pipe(replaceQueryInParsedUrl, mapUrlWithParsedQuery)); | ||
var parsePath = pipe_1.pipe(urlHelpers.parse, function (_a) { | ||
@@ -58,0 +73,0 @@ var search = _a.search, pathname = _a.pathname; |
@@ -13,2 +13,12 @@ "use strict"; | ||
}), 'http://foo.com/?string=string&number=1&boolean=true&strings=string1&strings=string2'); | ||
assert.strictEqual(index_1.replaceQueryInUrl({ | ||
url: 'http://foo.com/?string=string&number=1&boolean=true&strings=string1&strings=string2', | ||
})({ | ||
newQuery: { foo: 1 }, | ||
}), 'http://foo.com/?foo=1'); | ||
assert.strictEqual(index_1.replaceQueryInUrl({ | ||
url: 'http://foo.com/?string=string&number=1&boolean=true&strings=string1&strings=string2', | ||
})({ | ||
newQuery: {}, | ||
}), 'http://foo.com/'); | ||
assert.strictEqual(index_1.addQueryToUrl({ url: 'http://foo:bar@baz.com/' })({ | ||
@@ -15,0 +25,0 @@ queryToAppend: { a: 'b' }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19278
231
36