问题描述
IANA has a list of reserved domains,在测试和文档中。最有名的可能是example.com和example.org。
对于使用非常短的URL的系统的文档和设计,我正在寻找等效的const objectScan = require('object-scan');
const prune = (type,input) => {
objectScan(['**.nodes[*].type'],{
filterFn: ({ key,value,parents }) => {
if (value === type) {
parents[1].splice(key[key.length - 2],1);
}
}
})(input);
};
const json = {
navigations: [{
disp_order: '1',menu_id: '25266',nodes: [{
disp_order: '2',menu_id: '18951',type: 'DOC'
}],type: 'MENU'
},{
disp_order: '20',menu_id: '25204',nodes: [{
disp_order: '1',menu_id: '10295',type: 'DOC'
},{
disp_order: '10',menu_id: '25207',nodes: [{
disp_order: '999',menu_id: '17250',type: 'DOC'
}],type: 'MENU'
},{
disp_order: '20',menu_id: '25209',menu_id: '18881',type: 'MENU'
}],type: 'MENU'
}]
};
prune('DOC',json);
console.log(JSON.stringify(json));
// => {"navigations":[{"disp_order":"1","menu_id":"25266","nodes":[],"type":"MENU"},{"disp_order":"20","menu_id":"25204","nodes":[{"disp_order":"10","menu_id":"25207","menu_id":"25209","type":"MENU"}],"type":"MENU"}]}
或t.co
。在该IANA资源上找不到任何简短的内容。
什么是最短的,正式的“示例”或“保留”域,以及URL?
解决方法
您引用的文档引用了RFC 2606,其中列出了所有所有保留域,它们是四个TLD:
.test
.example
.invalid
.localhost
和三个二级域:
example.com
example.net
example.org
其中最短的是.test
TLD。
诸如t.co
和bit.ly
之类的域是 real 域,具有单字母二级域名,并且规则至字母TLD。