[英]Naming convention for path elements
I'm actually looking for a good path convention and mostly where to store /
between elements: 实际上,我在寻找一个好的路径公约,并大多在哪里存储
/
元素之间:
const dir = "example/"
const dir = "example/"
const file = "/example1.md"
const file = "/example1.md"
Array.join('/')
) Array.join('/')
) I was looking into the URL convention to try to find a good practice but it didn't talk about the path. 我一直在寻找URL约定以尝试找到一种好的做法,但是它没有谈论路径。
Example 例
Let's see into a real example 让我们看一个真实的例子
const base_url = process.env.API_URL // http://localhost:3000(/)
const endpoint_path = "(/)users/auth(/)"
const endpoint_name = "(/)tfa-validation"
// Slash before of after
let path = base_url + endpoint_path + endpoint_name;
// Or without slash
path = `${base_url}/${endpoint_path}/${endpoint_name}`;
path = [base_url, endpoint_path, endpoint_name].join('/')
Do a convention already exist ? 约定已经存在吗? Do a solution have any advantage ?
解决方案有什么优势吗?
I don't think there is any convention for this. 我认为这没有任何约定。 So, my opinion is:
所以,我的看法是:
const base_url = process.env.API_URL // http://localhost:3000
const endpoint_path = "users/auth"
const endpoint_name = "tfa-validation"
path = [base_url, endpoint_path, endpoint_name].join('/')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.