amis-rpc-design/node_modules/tldjs/lib/from-host.js

17 lines
326 B
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
"use strict";
/**
* Utility to extract the TLD from a hostname string
*
* @param {string} host
* @return {String}
*/
module.exports = function extractTldFromHost(hostname) {
var lastDotIndex = hostname.lastIndexOf('.');
if (lastDotIndex === -1) {
return null;
}
return hostname.substr(lastDotIndex + 1);
};