URL 对象上调用 toString() 方法将返回序列化的 URL。 返回值与 url.hrefurl.toJSON() 的相同。

由于需要符合标准,此方法不允许用户自定义 URL 的序列化过程。 如果需要更大灵活性,require('url').format() 可能更合适。

The toString() method on the URL object returns the serialized URL. The value returned is equivalent to that of url.href and url.toJSON().

Because of the need for standard compliance, this method does not allow users to customize the serialization process of the URL. For more flexibility, require('url').format() method might be of interest.