1"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[3875],{7469:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>l,contentTitle:()=>a,default:()=>c,frontMatter:()=>i,metadata:()=>o,toc:()=>p});var t=s(74848),r=s(28453);const i={title:"URL parsing",id:"url-parsing",slug:"/url-parsing",sidebar_label:"URL parsing",description:"Parse urls in Wing",keywords:["Wing language","URL"],image:"/img/wing-by-example.png",custom_edit_url:"https://github.com/winglang/wing/blob/main/docs/by-example/27-url-parsing.md"},a=void 0,o={id:"url-parsing",title:"URL parsing",description:"Parse urls in Wing",source:"@site/example_versioned_docs/version-latest/27-url-parsing.md",sourceDirName:".",slug:"/url-parsing",permalink:"/docs/learn/url-parsing",draft:!1,unlisted:!1,editUrl:"https://github.com/winglang/wing/blob/main/docs/by-example/27-url-parsing.md",tags:[],version:"latest",sidebarPosition:27,frontMatter:{title:"URL parsing",id:"url-parsing",slug:"/url-parsing",sidebar_label:"URL parsing",description:"Parse urls in Wing",keywords:["Wing language","URL"],image:"/img/wing-by-example.png",custom_edit_url:"https://github.com/winglang/wing/blob/main/docs/by-example/27-url-parsing.md"},sidebar:"defaultSidebar",previous:{title:"Number Parsing",permalink:"/docs/learn/number-parsing"},next:{title:"SHA256 Hashes",permalink:"/docs/learn/sha256"}},l={},p=[];function g(n){const e={code:"code",p:"p",pre:"pre",...(0,r.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.p,{children:"Parse urls using the http module, works with inflight closures."}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-js",metastring:'playground example title="main.w"',children:'bring http;\nbring cloud;\n\nnew cloud.Function(inflight () => {\n let parts = http.parseUrl("postgres://user:[email protected]:5432/path?k=v#f");\n\n log(parts.hostname);\n log(parts.host);\n log(parts.hash);\n log(parts.origin);\n log(parts.username);\n log(parts.password);\n log(parts.pathname);\n log(parts.port);\n log(parts.protocol);\n log(parts.search);\n\n});\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-bash",metastring:'title="Wing console output"',children:"# Run locally with wing console and invoke the cloud function\nhost.com\nhost.com:5432\n#f\nnull\nuser\npass\n/path\n5432\npostgres:\n?k=v\n"})})]})}function c(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(g,{...n})}):g(n)}},28453:(n,e,s)=>{s.d(e,{R:()=>a,x:()=>o});var t=s(96540);const r={},i=t.createContext(r);function a(n){const e=t.useContext(i);return t.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:a(n.components),t.createElement(i.Provider,{value:e},n.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.