Skip to content
File

Blob: src/workerd/api/node/url.h

cpp38 lines
1// Copyright (c) 2017-2022 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4#pragma once
5 
6#include <workerd/jsg/jsg.h>
7 
8#include <kj/string.h>
9 
10namespace workerd::api::node {
11 
12class UrlUtil final: public jsg::Object {
13 public:
14 UrlUtil() = default;
15 UrlUtil(jsg::Lock&, const jsg::Url&) {}
16 
17 jsg::JsString domainToUnicode(jsg::Lock& js, kj::String domain);
18 jsg::JsString domainToASCII(jsg::Lock& js, kj::String domain);
19 jsg::JsString format(
20 jsg::Lock& js, kj::String href, bool hash, bool unicode, bool search, bool auth);
21 jsg::JsString toASCII(jsg::Lock& js, kj::String url);
22 jsg::JsString canonicalizeIp(jsg::Lock& js, kj::String input);
23 
24 JSG_RESOURCE_TYPE(UrlUtil) {
25 JSG_METHOD(domainToUnicode);
26 JSG_METHOD(domainToASCII);
27 JSG_METHOD(canonicalizeIp);
28 
29 // Legacy APIs
30 JSG_METHOD(format);
31 JSG_METHOD(toASCII);
32 }
33};
34 
35#define EW_NODE_URL_ISOLATE_TYPES api::node::UrlUtil
36 
37} // namespace workerd::api::node