You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
790 B
JavaScript
34 lines
790 B
JavaScript
"use strict";
|
|
|
|
const modifyUrl = require("./");
|
|
|
|
let modified1 = modifyUrl("http://example.com/some/lengthy/path?with=a&query=string", {
|
|
hostname: "example.net",
|
|
query: {}
|
|
});
|
|
|
|
console.log(modified1); // http://example.net/some/lengthy/path
|
|
|
|
let modified2 = modifyUrl("http://example.com/?some=value", {
|
|
protocol: "https",
|
|
hostname: "subdomain.example.org",
|
|
port: 8443,
|
|
query: {
|
|
other: "value"
|
|
}
|
|
}, { mergeQuery: true });
|
|
|
|
console.log(modified2); // https://subdomain.example.org:8443/?some=value&other=value
|
|
|
|
let modified3 = modifyUrl("http://example.com/path", {
|
|
host: "example.org:8080"
|
|
});
|
|
|
|
console.log(modified3); // http://example.org:8080/path
|
|
|
|
let modified4 = modifyUrl("http://example.com/path", {
|
|
port: 8080
|
|
});
|
|
|
|
console.log(modified4); // http://example.com:8080/path
|