@stryke/url 0.2.1 â 0.2.3
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/README.md +2 -1
- package/dist/storm-url.d.ts +2 -2
- package/dist/storm-url.mjs +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This package is part of Storm Software's **đŠī¸ Stryke** monorepo. Stryke pac
|
|
|
22
22
|
|
|
23
23
|
<h3 align="center">đģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
24
24
|
|
|
25
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
26
26
|
|
|
27
27
|
> [!IMPORTANT] Important
|
|
28
28
|
> This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be available through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.
|
|
@@ -46,6 +46,7 @@ utilities.
|
|
|
46
46
|
|
|
47
47
|
<!-- START doctoc -->
|
|
48
48
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
49
|
+
|
|
49
50
|
## Table of Contents
|
|
50
51
|
|
|
51
52
|
- [Installing](#installing)
|
package/dist/storm-url.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ParsedURL } from "ufo";
|
|
2
|
-
import type {
|
|
2
|
+
import type { StormURLInterface, StormURLOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* A class used to build URLs
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@ import type { IStormURL, StormURLOptions } from "./types";
|
|
|
8
8
|
*
|
|
9
9
|
* The [UFO](https://github.com/unjs/ufo) library is used under the hood to parse and stringify URLs.
|
|
10
10
|
*/
|
|
11
|
-
export declare class StormURL implements
|
|
11
|
+
export declare class StormURL implements StormURLInterface, URL {
|
|
12
12
|
#private;
|
|
13
13
|
constructor(initialURL: string, options?: StormURLOptions);
|
|
14
14
|
set params(value: Record<string, any>);
|
package/dist/storm-url.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StormJSON as e}from"@stryke/json/storm-json";import{joinPaths as m}from"@stryke/path/join-paths";import{isInteger as g}from"@stryke/type-checks/is-integer";import{isSetString as l}from"@stryke/type-checks/is-set-string";import{isUndefined as b}from"@stryke/type-checks/is-undefined";import{cleanDoubleSlashes as d,decode as
|
|
1
|
+
import{StormJSON as e}from"@stryke/json/storm-json";import{joinPaths as m}from"@stryke/path/join-paths";import{isInteger as g}from"@stryke/type-checks/is-integer";import{isSetString as l}from"@stryke/type-checks/is-set-string";import{isUndefined as b}from"@stryke/type-checks/is-undefined";import{cleanDoubleSlashes as d,decode as f,isEqual as S,isNonEmptyURL as R,isRelative as L,isSamePath as U,isScriptProtocol as P,normalizeURL as y,parseAuth as n,parseHost as p,parsePath as $,parseQuery as c,parseURL as u,stringifyParsedURL as h,stringifyQuery as E}from"ufo";import{formatLocalePath as O}from"./helpers";export class StormURL{#a;#t;#s;#i;#r;#o;#e=[];#h;#n;constructor(t,s={decode:!0}){this.#a=s;const i=u(this.#a.decode?f(t):t),a=n(i.auth);this.#t=a.username,this.#s=a.password;const o=p(i.host);this.#i=o.hostname,this.#r=o.port,this.#o=i.protocol,this.#h=i.hash||"",this.#n=c(i.search),this.#e=i.pathname?i.pathname.split("/").filter(Boolean):[],s.locale&&this.#e.unshift(O((l(s.locale)?s.locale:process.env.DEFAULT_LOCALE)||"en-us"))}set params(t){this.#n=t}get params(){return this.#n}get searchParams(){const t=new URLSearchParams;for(const[s,i]of Object.entries(this.params))t.append(s,i);return t}set searchParams(t){this.params=Object.fromEntries(t.entries())}set search(t){this.params=c(t)}get search(){const t=E(this.params);return t?t.startsWith("?")?t:`?${t}`:""}set hash(t){this.#h=t.startsWith("#")?t:`#${t}`}get hash(){return this.#h}set port(t){this.#r=!b(t)&&g(t)?`${t}`:""}get port(){return this.#r||""}set username(t){this.auth=`${t}:${this.#s}`}get username(){return this.#t||""}set password(t){this.auth=`${this.#t}:${t}`}get password(){return this.#s||""}set auth(t){const s=n(t);this.#t=s.username,this.#s=s.password}get auth(){return this.#t&&this.#s?`${this.#t}:${this.#s}`:this.#t?this.#t:this.#s?this.#s:""}set protocol(t){this.#o=t.endsWith(":")?t:t.endsWith("://")?t.slice(0,-2):`${t}:`}get protocol(){return this.#o||this.#a.defaultProtocol||"https:"}set hostname(t){this.#i=t}get hostname(){return this.#i}set host(t){const s=p(t);this.#i=s.hostname,this.#r=s.port}get host(){return this.#i&&this.#r?`${this.#i}:${this.#r}`:this.#i?this.#i:this.#r?this.#r:""}set paths(t){this.#e=t.filter(Boolean)}get paths(){return this.#e}set pathname(t){this.paths=d(t).split("/")}get pathname(){return`/${this.paths?m(...this.paths.map(t=>e.stringify(t))):""}`}set path(t){const s=$(t);this.pathname=s.pathname,this.search=s.search,this.#h=s.hash}get path(){return h({pathname:this.pathname,search:this.search,hash:this.hash})}get href(){return this.toString()}set href(t){const s=u(t);this.protocol=s.protocol||this.protocol,this.auth=s.auth||this.auth,this.host=s.host||this.host,this.pathname=s.pathname||this.pathname,this.search=s.search||this.search,this.hash=s.hash||this.hash}get origin(){return`${this.protocol}//${this.host}`}get isScriptProtocol(){return P(this.protocol)}get isRelative(){return L(this.toString())}get isNonEmptyURL(){return R(this.toString())}get __typename(){return"StormURL"}isSamePath(t){return U(this.path,t)}isEqual(t){return S(this.toString(),typeof t=="string"?t:t instanceof StormURL?t.toString():h(t))}toParsed(){return{protocol:this.protocol,auth:this.auth,host:this.host,pathname:this.pathname,search:this.search,hash:this.hash}}toString(){return h(this.toParsed())}toEncoded(){return y(this.toString())}toJSON(){return e.stringify(this.toParsed())}}e.instance.registerCustom({isApplicable:r=>r.__typename==="StormURL",serialize:r=>r.toEncoded(),deserialize:r=>new StormURL(r,{decode:!0})},"StormURL");
|
package/dist/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface StormURLOptions {
|
|
|
17
17
|
defaultProtocol?: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const PROTOCOL_RELATIVE_SYMBOL: unique symbol;
|
|
20
|
-
export interface
|
|
20
|
+
export interface StormURLInterface extends URL {
|
|
21
21
|
/**
|
|
22
22
|
* A string containing the username and password specified before the domain name.
|
|
23
23
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/url",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing the `StormURL` class, which is used to parse and manipulate URLs.",
|
|
6
6
|
"repository": {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"private": false,
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"ufo": "1.5.4",
|
|
14
|
-
"@stryke/json": "^0.9.
|
|
15
|
-
"@stryke/path": "^0.
|
|
16
|
-
"@stryke/type-checks": "^0.3.
|
|
14
|
+
"@stryke/json": "^0.9.2",
|
|
15
|
+
"@stryke/path": "^0.10.1",
|
|
16
|
+
"@stryke/type-checks": "^0.3.5"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": { "@types/node": "^22.14.0" },
|
|
19
19
|
"publishConfig": { "access": "public" },
|
|
@@ -116,5 +116,6 @@
|
|
|
116
116
|
},
|
|
117
117
|
"main": "./dist/index.cjs",
|
|
118
118
|
"module": "./dist/index.mjs",
|
|
119
|
-
"types": "./dist/index.d.ts"
|
|
119
|
+
"types": "./dist/index.d.ts",
|
|
120
|
+
"gitHead": "a8c829509eefd6d8e5fcdc84bd5b9a0b8e02ee7e"
|
|
120
121
|
}
|