从 JSON 构建 URL [英] Build URLS from JSON

查看:34
本文介绍了从 JSON 构建 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个函数,可以像这样构建嵌套的 url.我想知道是否存在一个更主流的库来构建这样的 urls/uris.我宁愿使用标准.

I've created a function that can build nested urls like so. I was wondering if there existed a more mainstream library to build urls / uris like this. I'd rather use a standard.

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

推荐答案

正确答案是 node's built in URL图书馆.

The correct answer is node's built in URL library.

特别

url.format(urlObj)

这篇关于从 JSON 构建 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆