このようにネストされた URL を作成できる関数を作成しました。このような URL / URI を構築するためのより主流のライブラリが存在するかどうか疑問に思っていました。私はむしろ標準を使用したいと思います。
utility.urlConstruct({
"scheme": "https://",
"domain": "domain.com",
"path": "/login",
"query":{
"user":"thomasreggi",
"from":utility.urlConstruct({
"scheme": "https://",
"domain": "redirect.com",
"path": "/funstuff",
}),
}
});
吐き出す
https://domain.com/login?user=thomasreggi&from=https%3A%2F%2Fredirect.com%2Ffunstuff