@naverpay/nurl 0.1.1 → 1.0.0-canary.250526-ac39ceb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/nurl.js CHANGED
@@ -1 +1 @@
1
- "use strict";const m=require("./punycode.js"),r=require("./utils.js");class i{constructor(t){if(this._href="",this._protocol="",this._host="",this._hostname="",this._port="",this._pathname="",this._search="",this._hash="",this._origin="",this._username="",this._password="",this._baseUrl="",this._searchParams=new URLSearchParams,this._basePath="",this.punycodePrefix="xn--",this._searchParams=new URLSearchParams,typeof t=="string"||t instanceof URL)this.href=t.toString();else if(t){if(t.basePath&&(this._basePath=t.basePath.startsWith("/")?t.basePath:`/${t.basePath}`),t.baseUrl&&(this.baseUrl=t.baseUrl),t.href&&(this.href=t.href),t.protocol&&(this.protocol=t.protocol),t.host&&(this.host=t.host),t.hostname&&(this.hostname=t.hostname),t.port&&(this.port=t.port),t.pathname){const s=this._basePath;let e=t.pathname;s&&!e.startsWith(s)&&(e=`${s}${e.startsWith("/")?"":"/"}${e}`),this.pathname=r.refinePathnameWithQuery(e,t.query??{})}if(t.search&&(this.search=t.search),t.hash&&(this.hash=t.hash),t.username&&(this.username=t.username),t.password&&(this.password=t.password),t.query){const s=r.refineQueryWithPathname(t.pathname??"",t.query);Object.keys(s).length>0&&(this.search=new URLSearchParams(r.convertQueryToArray(s)).toString())}this.updateHref()}}static withBasePath(t){return s=>typeof s=="string"||s instanceof URL?new i({href:s.toString(),basePath:t}):new i({...s,basePath:t})}static create(t){return new i(t)}static canParse(t){if(t.startsWith("/"))return/^\/[^?#]*(\?[^#]*)?(#.*)?$/.test(t);try{return new URL(t),!0}catch{return/^[^:/?#]+(\.[^:/?#]+)+(\/[^?#]*(\?[^#]*)?(#.*)?)?$/.test(t)}}get baseUrl(){return this._baseUrl}set baseUrl(t){this._baseUrl=t;try{const s=new URL(t);this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._origin=s.origin,this._username=s.username,this._password=s.password,s.pathname!=="/"&&(this._pathname=s.pathname),s.search&&(this._search=s.search,this._searchParams=new URLSearchParams(s.search)),s.hash&&(this._hash=s.hash),this.updateHref()}catch(s){console.warn(`Invalid baseUrl: ${t}`,s)}}get href(){return this.pathname.length===1?`${this._href}/`:this._href}set href(t){try{const s=new URL(t);this._href=s.href,this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._pathname=s.pathname,this._search=s.search,this._hash=s.hash,this._origin=s.origin,this._username=s.username,this._password=s.password,this._searchParams=s.searchParams}catch(s){const e=i.parseStringToURLLike(t);if(!e)throw console.warn(`Can not parse ${t}`),s;this._href=e.href,this._protocol=e.protocol,this._host=e.hostname,this._hostname=e.hostname,this._port=e.port,this._pathname=e.pathname,this._search=e.search,this._hash=e.hash,this._origin=e.origin,this._username=e.username,this._password=e.password,this._searchParams=e.searchParams}}static parseStringToURLLike(t){const s=/^(?:(https?:\/\/)(?:([^:@]+)(?::([^@]+))?@)?((?:[^/:?#]+)(?::(\d+))?)?)?([/][^?#]*)?(\?[^#]*)?(#.*)?$/,e=t.match(s),[h=t,a="",n="",d="",o="",c="",p="",_="",f=""]=e||[];if(!e||a&&!o&&!p&&!_&&!f)return null;const P=a&&o?`${a}//${o}${c?`:${c}`:""}`:"";return{href:h,protocol:a,host:o,hostname:o,port:c,pathname:t?p||"/":"",search:_,hash:f,origin:P,username:n,password:d,searchParams:new URLSearchParams(_)}}get protocol(){return this._protocol}set protocol(t){this._protocol=t,this.updateHref()}get host(){return this._host}set host(t){const[s,e]=t.split(":"),h=this.encodeHostname(s);this._host=e?`${h}:${e}`:h,this._hostname=h,this._port=e||"",this.updateHref()}get hostname(){return this._hostname}set hostname(t){const s=this.encodeHostname(t);this._hostname=s,this._host=this._port?`${s}:${this._port}`:s,this.updateHref()}get port(){return this._port}set port(t){this._port=t,this._host=`${this._hostname}${t?":"+t:""}`,this.updateHref()}get pathname(){return this._pathname}set pathname(t){let s=t;this._basePath&&!s.startsWith(this._basePath)&&(s=`${this._basePath}${s.startsWith("/")?"":"/"}${s}`);const e=s.split("/").map(h=>r.isDynamicPath(h)?h:encodeURI(h)).join("/");this._pathname=e.startsWith("/")?e:`/${e}`,this.updateHref()}get search(){return this._search}set search(t){this._search=t.startsWith("?")?t:`?${t}`,this._searchParams=new URLSearchParams(t),this.updateHref()}setSearchParams(t){const s=new URLSearchParams(t);this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}appendSearchParams(t){const s=new URLSearchParams(this._searchParams),e=r.getDynamicPaths(this._pathname).map(r.extractPathKey);Object.keys(t).forEach(h=>{e.includes(h)?this._pathname=r.refinePathnameWithQuery(this._pathname,{[h]:t[h]}):s.append(h,t[h])}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}removeSearchParams(...t){const s=new URLSearchParams(this._searchParams);t.forEach(e=>{s.delete(e)}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}get searchParams(){return new Proxy(this._searchParams,{get:(t,s,e)=>{const h=Reflect.get(t,s,e);return typeof h=="function"?(...a)=>{const n=h.apply(t,a);return this._search=this._searchParams.toString()?`?${this._searchParams.toString()}`:"",this.updateHref(),n}:h}})}get hash(){return this._hash}set hash(t){this._hash=t.startsWith("#")?t:`#${t}`,this.updateHref()}get origin(){return this._origin}get username(){return this._username}set username(t){this._username=t,this.updateHref()}get password(){return this._password}set password(t){this._password=t,this.updateHref()}updateHref(){if(this._baseUrl){const t=new URL(this._baseUrl);t.pathname=this._pathname,t.search=this._search,t.hash=this._hash,this._href=t.href,this._origin=t.origin}else this._href=`${this._protocol}${this._protocol&&"//"}${this._username}${this._password?":"+this._password:""}${this._username||this._password?"@":""}${this._hostname}${this._port?":"+this._port:""}${this._pathname==="/"?"":this._pathname}${this._search}${this._hash}`,this._origin=`${this._protocol}//${this._hostname}${this._port?":"+this._port:""}`}toString(){return this.href}toJSON(){return this.href}encodeHostname(t){return t.split(".").map(s=>{for(const e of s)if(r.isASCIICodeChar(e))return`${this.punycodePrefix}${m.encode(s)}`;return s}).join(".")}get decodedIDN(){let t=this._href;return this._hostname.split(".").forEach(s=>{t=t.replace(s,m.decode(s.replace(this.punycodePrefix,"")))}),t}get decodedHostname(){return this._hostname.split(".").map(t=>m.decode(t.replace(this.punycodePrefix,""))).join(".")}}module.exports=i;
1
+ "use strict";const m=require("./punycode.js"),r=require("./utils.js");class i{constructor(t){if(this._href="",this._protocol="",this._host="",this._hostname="",this._port="",this._pathname="",this._search="",this._hash="",this._origin="",this._username="",this._password="",this._baseUrl="",this._searchParams=new URLSearchParams,this._basePath="",this.punycodePrefix="xn--",this._searchParams=new URLSearchParams,typeof t=="string"||t instanceof URL)this.href=t.toString();else if(t){if(t.basePath&&(this._basePath=t.basePath.startsWith("/")?t.basePath:`/${t.basePath}`),t.baseUrl&&(this.baseUrl=t.baseUrl),t.href&&(this.href=t.href),t.protocol&&(this.protocol=t.protocol),t.host&&(this.host=t.host),t.hostname&&(this.hostname=t.hostname),t.port&&(this.port=t.port),t.pathname!==void 0?t.pathname===""?this._pathname="":this.pathname=r.refinePathnameWithQuery(t.pathname,t.query??{}):this._pathname="",t.search&&(this.search=t.search),t.hash&&(this.hash=t.hash),t.username&&(this.username=t.username),t.password&&(this.password=t.password),t.query){const s=r.refineQueryWithPathname(t.pathname??"",t.query);Object.keys(s).length>0&&(this.search=new URLSearchParams(r.convertQueryToArray(s)).toString())}this.updateHref()}}static withBasePath(t){return s=>typeof s=="string"||s instanceof URL?new i({href:s.toString(),basePath:t}):new i({...s,basePath:t})}static create(t){return new i(t)}static canParse(t){if(t.startsWith("/"))return/^\/[^?#]*(\?[^#]*)?(#.*)?$/.test(t);try{return new URL(t),!0}catch{return/^[^:/?#]+(\.[^:/?#]+)+(\/[^?#]*(\?[^#]*)?(#.*)?)?$/.test(t)}}get baseUrl(){return this._baseUrl}set baseUrl(t){this._baseUrl=t;try{const s=new URL(t);this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._origin=s.origin,this._username=s.username,this._password=s.password,s.pathname!=="/"&&(this._pathname=s.pathname),s.search&&(this._search=s.search,this._searchParams=new URLSearchParams(s.search)),s.hash&&(this._hash=s.hash),this.updateHref()}catch(s){console.warn(`Invalid baseUrl: ${t}`,s)}}get href(){return this._href}set href(t){try{const s=new URL(t);this._href=s.href,this._protocol=s.protocol,this._host=s.host,this._hostname=s.hostname,this._port=s.port,this._pathname=s.pathname,this._search=s.search,this._hash=s.hash,this._origin=s.origin,this._username=s.username,this._password=s.password,this._searchParams=s.searchParams}catch(s){const e=i.parseStringToURLLike(t);if(!e)throw console.warn(`Can not parse ${t}`),s;this._href=e.href,this._protocol=e.protocol,this._host=e.hostname,this._hostname=e.hostname,this._port=e.port,this._pathname=e.pathname,this._search=e.search,this._hash=e.hash,this._origin=e.origin,this._username=e.username,this._password=e.password,this._searchParams=e.searchParams}}static parseStringToURLLike(t){const s=/^(?:(https?:\/\/)(?:([^:@]+)(?::([^@]+))?@)?((?:[^/:?#]+)(?::(\d+))?)?)?([/][^?#]*)?(\?[^#]*)?(#.*)?$/,e=t.match(s),[h=t,a="",n="",d="",o="",c="",p="",_="",f=""]=e||[];if(!e||a&&!o&&!p&&!_&&!f)return null;const P=a&&o?`${a}//${o}${c?`:${c}`:""}`:"";return{href:h,protocol:a,host:o,hostname:o,port:c,pathname:t?p||"/":"",search:_,hash:f,origin:P,username:n,password:d,searchParams:new URLSearchParams(_)}}get protocol(){return this._protocol}set protocol(t){this._protocol=t,this.updateHref()}get host(){return this._host}set host(t){const[s,e]=t.split(":"),h=this.encodeHostname(s);this._host=e?`${h}:${e}`:h,this._hostname=h,this._port=e||"",this.updateHref()}get hostname(){return this._hostname}set hostname(t){const s=this.encodeHostname(t);this._hostname=s,this._host=this._port?`${s}:${this._port}`:s,this.updateHref()}get port(){return this._port}set port(t){this._port=t,this._host=`${this._hostname}${t?":"+t:""}`,this.updateHref()}get pathname(){return this._pathname}set pathname(t){let s=t;if(t===""){s="/",this._pathname=s,this.updateHref();return}this._basePath&&!s.startsWith(this._basePath)&&(s=`${this._basePath}${s.startsWith("/")?"":"/"}${s}`);const e=s.split("/").map(h=>r.isDynamicPath(h)?h:encodeURI(h)).join("/");this._pathname=e.startsWith("/")?e:`/${e}`,this.updateHref()}get search(){return this._search}set search(t){this._search=t.startsWith("?")?t:`?${t}`,this._searchParams=new URLSearchParams(t),this.updateHref()}setSearchParams(t){const s=new URLSearchParams(t);this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}appendSearchParams(t){const s=new URLSearchParams(this._searchParams),e=r.getDynamicPaths(this._pathname).map(r.extractPathKey);Object.keys(t).forEach(h=>{e.includes(h)?this._pathname=r.refinePathnameWithQuery(this._pathname,{[h]:t[h]}):s.append(h,t[h])}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}removeSearchParams(...t){const s=new URLSearchParams(this._searchParams);t.forEach(e=>{s.delete(e)}),this._search=s.toString()?`?${s.toString()}`:"",this._searchParams=s,this.updateHref()}get searchParams(){return new Proxy(this._searchParams,{get:(t,s,e)=>{const h=Reflect.get(t,s,e);return typeof h=="function"?(...a)=>{const n=h.apply(t,a);return this._search=this._searchParams.toString()?`?${this._searchParams.toString()}`:"",this.updateHref(),n}:h}})}get hash(){return this._hash}set hash(t){this._hash=t.startsWith("#")?t:`#${t}`,this.updateHref()}get origin(){return this._origin}get username(){return this._username}set username(t){this._username=t,this.updateHref()}get password(){return this._password}set password(t){this._password=t,this.updateHref()}updateHref(){const t=this._pathname;if(this._baseUrl){const s=new URL(this._baseUrl);s.pathname=t,s.search=this._search,s.hash=this._hash,this._href=s.href,this._origin=s.origin}else this._href=`${this._protocol}${this._protocol&&"//"}${this._username}${this._password?":"+this._password:""}${this._username||this._password?"@":""}${this._hostname}${this._port?":"+this._port:""}${t}${this._search}${this._hash}`,this._origin=`${this._protocol}//${this._hostname}${this._port?":"+this._port:""}`}toString(){return this.href}toJSON(){return this.href}encodeHostname(t){return t.split(".").map(s=>{for(const e of s)if(r.isASCIICodeChar(e))return`${this.punycodePrefix}${m.encode(s)}`;return s}).join(".")}get decodedIDN(){let t=this._href;return this._hostname.split(".").forEach(s=>{t=t.replace(s,m.decode(s.replace(this.punycodePrefix,"")))}),t}get decodedHostname(){return this._hostname.split(".").map(t=>m.decode(t.replace(this.punycodePrefix,""))).join(".")}}module.exports=i;
package/dist/esm/nurl.mjs CHANGED
@@ -1,18 +1,13 @@
1
1
  import { encode as l, decode as p } from "./punycode.mjs";
2
- import { refinePathnameWithQuery as f, refineQueryWithPathname as $, convertQueryToArray as g, isDynamicPath as u, getDynamicPaths as w, extractPathKey as S, isASCIICodeChar as U } from "./utils.mjs";
2
+ import { refinePathnameWithQuery as f, refineQueryWithPathname as g, convertQueryToArray as $, isDynamicPath as u, getDynamicPaths as w, extractPathKey as S, isASCIICodeChar as U } from "./utils.mjs";
3
3
  class i {
4
4
  constructor(t) {
5
5
  if (this._href = "", this._protocol = "", this._host = "", this._hostname = "", this._port = "", this._pathname = "", this._search = "", this._hash = "", this._origin = "", this._username = "", this._password = "", this._baseUrl = "", this._searchParams = new URLSearchParams(), this._basePath = "", this.punycodePrefix = "xn--", this._searchParams = new URLSearchParams(), typeof t == "string" || t instanceof URL)
6
6
  this.href = t.toString();
7
7
  else if (t) {
8
- if (t.basePath && (this._basePath = t.basePath.startsWith("/") ? t.basePath : `/${t.basePath}`), t.baseUrl && (this.baseUrl = t.baseUrl), t.href && (this.href = t.href), t.protocol && (this.protocol = t.protocol), t.host && (this.host = t.host), t.hostname && (this.hostname = t.hostname), t.port && (this.port = t.port), t.pathname) {
9
- const s = this._basePath;
10
- let h = t.pathname;
11
- s && !h.startsWith(s) && (h = `${s}${h.startsWith("/") ? "" : "/"}${h}`), this.pathname = f(h, t.query ?? {});
12
- }
13
- if (t.search && (this.search = t.search), t.hash && (this.hash = t.hash), t.username && (this.username = t.username), t.password && (this.password = t.password), t.query) {
14
- const s = $(t.pathname ?? "", t.query);
15
- Object.keys(s).length > 0 && (this.search = new URLSearchParams(g(s)).toString());
8
+ if (t.basePath && (this._basePath = t.basePath.startsWith("/") ? t.basePath : `/${t.basePath}`), t.baseUrl && (this.baseUrl = t.baseUrl), t.href && (this.href = t.href), t.protocol && (this.protocol = t.protocol), t.host && (this.host = t.host), t.hostname && (this.hostname = t.hostname), t.port && (this.port = t.port), t.pathname !== void 0 ? t.pathname === "" ? this._pathname = "" : this.pathname = f(t.pathname, t.query ?? {}) : this._pathname = "", t.search && (this.search = t.search), t.hash && (this.hash = t.hash), t.username && (this.username = t.username), t.password && (this.password = t.password), t.query) {
9
+ const s = g(t.pathname ?? "", t.query);
10
+ Object.keys(s).length > 0 && (this.search = new URLSearchParams($(s)).toString());
16
11
  }
17
12
  this.updateHref();
18
13
  }
@@ -51,26 +46,26 @@ class i {
51
46
  }
52
47
  }
53
48
  get href() {
54
- return this.pathname.length === 1 ? `${this._href}/` : this._href;
49
+ return this._href;
55
50
  }
56
51
  set href(t) {
57
52
  try {
58
53
  const s = new URL(t);
59
54
  this._href = s.href, this._protocol = s.protocol, this._host = s.host, this._hostname = s.hostname, this._port = s.port, this._pathname = s.pathname, this._search = s.search, this._hash = s.hash, this._origin = s.origin, this._username = s.username, this._password = s.password, this._searchParams = s.searchParams;
60
55
  } catch (s) {
61
- const h = i.parseStringToURLLike(t);
62
- if (!h)
56
+ const e = i.parseStringToURLLike(t);
57
+ if (!e)
63
58
  throw console.warn(`Can not parse ${t}`), s;
64
- this._href = h.href, this._protocol = h.protocol, this._host = h.hostname, this._hostname = h.hostname, this._port = h.port, this._pathname = h.pathname, this._search = h.search, this._hash = h.hash, this._origin = h.origin, this._username = h.username, this._password = h.password, this._searchParams = h.searchParams;
59
+ this._href = e.href, this._protocol = e.protocol, this._host = e.hostname, this._hostname = e.hostname, this._port = e.port, this._pathname = e.pathname, this._search = e.search, this._hash = e.hash, this._origin = e.origin, this._username = e.username, this._password = e.password, this._searchParams = e.searchParams;
65
60
  }
66
61
  }
67
62
  static parseStringToURLLike(t) {
68
- const s = /^(?:(https?:\/\/)(?:([^:@]+)(?::([^@]+))?@)?((?:[^/:?#]+)(?::(\d+))?)?)?([/][^?#]*)?(\?[^#]*)?(#.*)?$/, h = t.match(s), [e = t, r = "", o = "", d = "", a = "", n = "", _ = "", c = "", m = ""] = h || [];
69
- if (!h || r && !a && !_ && !c && !m)
63
+ const s = /^(?:(https?:\/\/)(?:([^:@]+)(?::([^@]+))?@)?((?:[^/:?#]+)(?::(\d+))?)?)?([/][^?#]*)?(\?[^#]*)?(#.*)?$/, e = t.match(s), [h = t, r = "", o = "", d = "", a = "", n = "", _ = "", c = "", m = ""] = e || [];
64
+ if (!e || r && !a && !_ && !c && !m)
70
65
  return null;
71
66
  const P = r && a ? `${r}//${a}${n ? `:${n}` : ""}` : "";
72
67
  return {
73
- href: e,
68
+ href: h,
74
69
  protocol: r,
75
70
  host: a,
76
71
  hostname: a,
@@ -94,8 +89,8 @@ class i {
94
89
  return this._host;
95
90
  }
96
91
  set host(t) {
97
- const [s, h] = t.split(":"), e = this.encodeHostname(s);
98
- this._host = h ? `${e}:${h}` : e, this._hostname = e, this._port = h || "", this.updateHref();
92
+ const [s, e] = t.split(":"), h = this.encodeHostname(s);
93
+ this._host = e ? `${h}:${e}` : h, this._hostname = h, this._port = e || "", this.updateHref();
99
94
  }
100
95
  get hostname() {
101
96
  return this._hostname;
@@ -115,9 +110,13 @@ class i {
115
110
  }
116
111
  set pathname(t) {
117
112
  let s = t;
113
+ if (t === "") {
114
+ s = "/", this._pathname = s, this.updateHref();
115
+ return;
116
+ }
118
117
  this._basePath && !s.startsWith(this._basePath) && (s = `${this._basePath}${s.startsWith("/") ? "" : "/"}${s}`);
119
- const h = s.split("/").map((e) => u(e) ? e : encodeURI(e)).join("/");
120
- this._pathname = h.startsWith("/") ? h : `/${h}`, this.updateHref();
118
+ const e = s.split("/").map((h) => u(h) ? h : encodeURI(h)).join("/");
119
+ this._pathname = e.startsWith("/") ? e : `/${e}`, this.updateHref();
121
120
  }
122
121
  get search() {
123
122
  return this._search;
@@ -130,27 +129,27 @@ class i {
130
129
  this._search = s.toString() ? `?${s.toString()}` : "", this._searchParams = s, this.updateHref();
131
130
  }
132
131
  appendSearchParams(t) {
133
- const s = new URLSearchParams(this._searchParams), h = w(this._pathname).map(S);
134
- Object.keys(t).forEach((e) => {
135
- h.includes(e) ? this._pathname = f(this._pathname, {
136
- [e]: t[e]
137
- }) : s.append(e, t[e]);
132
+ const s = new URLSearchParams(this._searchParams), e = w(this._pathname).map(S);
133
+ Object.keys(t).forEach((h) => {
134
+ e.includes(h) ? this._pathname = f(this._pathname, {
135
+ [h]: t[h]
136
+ }) : s.append(h, t[h]);
138
137
  }), this._search = s.toString() ? `?${s.toString()}` : "", this._searchParams = s, this.updateHref();
139
138
  }
140
139
  removeSearchParams(...t) {
141
140
  const s = new URLSearchParams(this._searchParams);
142
- t.forEach((h) => {
143
- s.delete(h);
141
+ t.forEach((e) => {
142
+ s.delete(e);
144
143
  }), this._search = s.toString() ? `?${s.toString()}` : "", this._searchParams = s, this.updateHref();
145
144
  }
146
145
  get searchParams() {
147
146
  return new Proxy(this._searchParams, {
148
- get: (t, s, h) => {
149
- const e = Reflect.get(t, s, h);
150
- return typeof e == "function" ? (...r) => {
151
- const o = e.apply(t, r);
147
+ get: (t, s, e) => {
148
+ const h = Reflect.get(t, s, e);
149
+ return typeof h == "function" ? (...r) => {
150
+ const o = h.apply(t, r);
152
151
  return this._search = this._searchParams.toString() ? `?${this._searchParams.toString()}` : "", this.updateHref(), o;
153
- } : e;
152
+ } : h;
154
153
  }
155
154
  });
156
155
  }
@@ -176,11 +175,12 @@ class i {
176
175
  this._password = t, this.updateHref();
177
176
  }
178
177
  updateHref() {
178
+ const t = this._pathname;
179
179
  if (this._baseUrl) {
180
- const t = new URL(this._baseUrl);
181
- t.pathname = this._pathname, t.search = this._search, t.hash = this._hash, this._href = t.href, this._origin = t.origin;
180
+ const s = new URL(this._baseUrl);
181
+ s.pathname = t, s.search = this._search, s.hash = this._hash, this._href = s.href, this._origin = s.origin;
182
182
  } else
183
- this._href = `${this._protocol}${this._protocol && "//"}${this._username}${this._password ? ":" + this._password : ""}${this._username || this._password ? "@" : ""}${this._hostname}${this._port ? ":" + this._port : ""}${this._pathname === "/" ? "" : this._pathname}${this._search}${this._hash}`, this._origin = `${this._protocol}//${this._hostname}${this._port ? ":" + this._port : ""}`;
183
+ this._href = `${this._protocol}${this._protocol && "//"}${this._username}${this._password ? ":" + this._password : ""}${this._username || this._password ? "@" : ""}${this._hostname}${this._port ? ":" + this._port : ""}${t}${this._search}${this._hash}`, this._origin = `${this._protocol}//${this._hostname}${this._port ? ":" + this._port : ""}`;
184
184
  }
185
185
  toString() {
186
186
  return this.href;
@@ -190,8 +190,8 @@ class i {
190
190
  }
191
191
  encodeHostname(t) {
192
192
  return t.split(".").map((s) => {
193
- for (const h of s)
194
- if (U(h))
193
+ for (const e of s)
194
+ if (U(e))
195
195
  return `${this.punycodePrefix}${l(s)}`;
196
196
  return s;
197
197
  }).join(".");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naverpay/nurl",
3
- "version": "0.1.1",
3
+ "version": "1.0.0-canary.250526-ac39ceb",
4
4
  "description": "URL build library",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -55,6 +55,7 @@
55
55
  "prettier:fix": "prettier --write '**/*.{json,yaml,md,ts,tsx,js,jsx}'",
56
56
  "release": "changeset publish",
57
57
  "markdownlint": "markdownlint '**/*.md' '#.changeset' '#**/CHANGELOG.md'",
58
- "markdownlint:fix": "markdownlint --fix '**/*.md' '#.changeset' '#**/CHANGELOG.md'"
58
+ "markdownlint:fix": "markdownlint --fix '**/*.md' '#.changeset' '#**/CHANGELOG.md'",
59
+ "release:canary": "pnpm run build && changeset publish --no-git-tag --tag=canary --directory dist"
59
60
  }
60
61
  }