Closed
Description
Hello everyone,
Please let me know if this is this has been decided to be like this or not, but when building an URL, query property only takes a string as value, instead of search() or query() that take both string and objects.
Heres an example code (online repl here):
const assert = require('assert');
const URI = require('urijs');
const PROTOCOL = 'http';
const HOST = 'mycustom.domain.com';
const PORT = '443';
const BASE_PATH = '/some//path/';
const resource = '///resource//5';
const query = {
myQuery: 'rocks'
}
const constructorURI = new URI({
protocol: PROTOCOL,
hostname: HOST,
port: PORT,
path: `${BASE_PATH}/${resource}/`,
query,
}).normalize();
const searchURI = new URI({
protocol: PROTOCOL,
hostname: HOST,
port: PORT,
path: `${BASE_PATH}/${resource}/`,
}).search(query).normalize();
assert(constructorURI.toString() === searchURI.toString(), 'URIs are not equal');
Metadata
Metadata
Assignees
Labels
No labels