Skip to content

Commit

Permalink
(chore) update versions (#55)
Browse files Browse the repository at this point in the history
* (chore) update versions

* (fix) Add missing build files

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nicolas Brassard <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2025
1 parent 2fc065b commit 417de9c
Show file tree
Hide file tree
Showing 23 changed files with 173 additions and 33 deletions.
5 changes: 0 additions & 5 deletions .changeset/fifty-pets-walk.md

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/changeset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
run: pnpm sync
- name: build
run: pnpm build
- name: add build files
run: git add .
- name: create and publish versions
uses: changesets/action@v1
with:
Expand Down
7 changes: 7 additions & 0 deletions packages/components/html-elements/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @288-toolkit/html-elements

## 3.1.4

### Patch Changes

- Updated dependencies [2fc065b]
- @288-toolkit/url@5.2.0

## 3.1.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/components/html-elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/html-elements",
"version": "3.1.3",
"version": "3.1.4",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
8 changes: 8 additions & 0 deletions packages/components/video-embed/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @288-toolkit/video-embed

## 4.0.6

### Patch Changes

- Updated dependencies [2fc065b]
- @288-toolkit/url@5.2.0
- @288-toolkit/html-elements@3.1.4

## 4.0.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/components/video-embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/video-embed",
"version": "4.0.5",
"version": "4.0.6",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
4 changes: 4 additions & 0 deletions packages/hooks/dist/server/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export const preflightCheck = ({ event, resolve }) => {
event.url.pathname.startsWith('/wp-includes')) {
return error404();
}
// Empty responses for .well-known/ requests
if (event.url.pathname.startsWith('/.well-known/')) {
return error404();
}
return resolve(event);
};
/**
Expand Down
6 changes: 6 additions & 0 deletions packages/url/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @288-toolkit/url

## 5.2.0

### Minor Changes

- 2fc065b: Refactor the code around parsed and entry

## 5.1.2

### Patch Changes
Expand Down
4 changes: 4 additions & 0 deletions packages/url/dist/createEntryUrlBuilder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface EntryUrl {
* Returns the full URL string.
*/
toAbsolute(): Maybe<string>;
/**
* Returns the URL string without the protocol, composed of the hostname, pathname, search, and hash.
*/
toProtocolLess(): Maybe<string>;
/**
* Returns the URL string without the scheme, composed of the pathname, search, and hash.
*/
Expand Down
19 changes: 11 additions & 8 deletions packages/url/dist/createEntryUrlBuilder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { normalize, removeTrailingSlash } from '@288-toolkit/strings';
import { removeTrailingSlash } from '@288-toolkit/strings';
import { decodePath } from './decodePath.js';
import { protocolLessUrl, schemeLessUrl } from './lessUrl.js';
import { normalizePath } from './normalizePath.js';
import { urlCanParse } from './urlCanParse.js';
/**
* Creates a function that builds URLs for entries.
Expand All @@ -16,6 +19,7 @@ export const createEntryUrlBuilder = ({ siteUrl, shouldRemoveTrailingSlash = tru
decodedPath: () => '',
normalizePath: () => empty,
toAbsolute: () => null,
toProtocolLess: () => null,
toSchemeLess: () => null,
/** @deprecated Use `toSchemeLess` instead. */
toLanguageRelative: () => null,
Expand All @@ -35,13 +39,10 @@ export const createEntryUrlBuilder = ({ siteUrl, shouldRemoveTrailingSlash = tru
const self = {
raw: url,
decodedPath() {
return url.pathname.split('/').map(decodeURIComponent).join('/');
return decodePath(url.pathname);
},
normalizePath() {
url.pathname = url.pathname
.split('/')
.map((part) => normalize(decodeURIComponent(part)))
.join('/');
url.pathname = normalizePath(url.pathname);
return self;
},
toString() {
Expand All @@ -50,9 +51,11 @@ export const createEntryUrlBuilder = ({ siteUrl, shouldRemoveTrailingSlash = tru
toAbsolute() {
return url.toString();
},
toProtocolLess() {
return protocolLessUrl(url);
},
toSchemeLess() {
const { pathname, hash, search } = url;
return `${pathname}${search}${hash}`;
return schemeLessUrl(url);
},
/** @deprecated Use `toSchemeLess` instead. */
toLanguageRelative() {
Expand Down
6 changes: 6 additions & 0 deletions packages/url/dist/decodePath.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Decodes the pathname by splitting it into parts, decoding each part, and joining them with slashes.
* @param pathname - The pathname to decode.
* @returns The decoded pathname.
*/
export declare const decodePath: (pathname: string) => string;
8 changes: 8 additions & 0 deletions packages/url/dist/decodePath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Decodes the pathname by splitting it into parts, decoding each part, and joining them with slashes.
* @param pathname - The pathname to decode.
* @returns The decoded pathname.
*/
export const decodePath = (pathname) => {
return pathname.split('/').map(decodeURIComponent).join('/');
};
2 changes: 1 addition & 1 deletion packages/url/dist/getLanguageRelativeUri.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Remove the home URI from a URI.
* @deprecated Use createEntryUrlBuilder instead.
* @deprecated This was used with Craft 4. With Craft 5, use createEntryUrlBuilder instead.
*/
export declare const getLanguageRelativeUri: (uri: string, homeUri: string) => string;
2 changes: 1 addition & 1 deletion packages/url/dist/getLanguageRelativeUri.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Remove the home URI from a URI.
* @deprecated Use createEntryUrlBuilder instead.
* @deprecated This was used with Craft 4. With Craft 5, use createEntryUrlBuilder instead.
*/
export const getLanguageRelativeUri = (uri, homeUri) => uri?.replace(homeUri, '') || '';
/* @enddeprecated */
4 changes: 3 additions & 1 deletion packages/url/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export * from './createEntryUrlBuilder.js';
export * from './decodePath.js';
export * from './isExternalUrl.js';
export * from './validateSameOrigin.js';
export * from './normalizePath.js';
export * from './parsedUrl.js';
export * from './urlCanParse.js';
export * from './validateSameOrigin.js';
4 changes: 3 additions & 1 deletion packages/url/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export * from './createEntryUrlBuilder.js';
export * from './decodePath.js';
export * from './isExternalUrl.js';
export * from './validateSameOrigin.js';
export * from './normalizePath.js';
export * from './parsedUrl.js';
export * from './urlCanParse.js';
export * from './validateSameOrigin.js';
12 changes: 12 additions & 0 deletions packages/url/dist/lessUrl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Returns the URL string without the protocol, composed of the hostname, pathname, search, and hash.
* It starts with a double slash.
* @param url - The URL to convert.
*/
export declare const protocolLessUrl: (url: URL) => string;
/**
* Returns the URL string without the scheme, composed of the pathname, search, and hash.
* It starts with a single slash.
* @param url - The URL to convert.
*/
export declare const schemeLessUrl: (url: URL) => string;
18 changes: 18 additions & 0 deletions packages/url/dist/lessUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Returns the URL string without the protocol, composed of the hostname, pathname, search, and hash.
* It starts with a double slash.
* @param url - The URL to convert.
*/
export const protocolLessUrl = (url) => {
const { hostname, pathname, hash, search } = url;
return `//${hostname}${pathname}${search}${hash}`;
};
/**
* Returns the URL string without the scheme, composed of the pathname, search, and hash.
* It starts with a single slash.
* @param url - The URL to convert.
*/
export const schemeLessUrl = (url) => {
const { pathname, hash, search } = url;
return `${pathname}${search}${hash}`;
};
7 changes: 7 additions & 0 deletions packages/url/dist/normalizePath.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Normalizes the pathname by decoding it, normalizing each part, and joining them with slashes.
* @see {@link @288-toolkit/strings#normalize}
* @param pathname - The pathname to normalize.
* @returns The normalized pathname.
*/
export declare const normalizePath: (pathname: string) => string;
13 changes: 13 additions & 0 deletions packages/url/dist/normalizePath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { normalize } from '@288-toolkit/strings';
/**
* Normalizes the pathname by decoding it, normalizing each part, and joining them with slashes.
* @see {@link @288-toolkit/strings#normalize}
* @param pathname - The pathname to normalize.
* @returns The normalized pathname.
*/
export const normalizePath = (pathname) => {
return pathname
.split('/')
.map((part) => normalize(decodeURIComponent(part)))
.join('/');
};
22 changes: 20 additions & 2 deletions packages/url/dist/parsedUrl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,27 @@ export declare const parsedUrl: (url: string | URL) => {
* The URL object.
*/
parsed: URL | null;
/**
* Checks if the URL is valid.
*/
valid: () => boolean;
/**
* Makes sure the pathname is properly encoded.
* This can be needed when the pathname contains special characters.
*
* @deprecated Pathname are always url encoded.
*/
encodePath: () => any | null;
/**
* Decodes the pathname and returns it.
* It can't be stored in the URL object because it would be encoded again.
*/
decodePath: () => string | null;
/**
* Normalizes the pathname by removing accents.
* @see {@link @288-toolkit/strings#normalize}
*/
normalizePath: () => any | null;
normalizePath: () => any;
/**
* Returns the full URL string.
*/
Expand All @@ -29,12 +39,20 @@ export declare const parsedUrl: (url: string | URL) => {
/**
* Returns the relative URL string.
* It starts with a single slash.
* @deprecated Relative URLs do not start with a single slash.
* They are relative to the current URL.
* Use `toSchemeLess()` instead.
*/
toRelative: () => string | null;
/**
* Returns the URL string without the scheme, composed of the pathname, search, and hash.
* It starts with a double slash.
* It starts with a single slash.
*/
toSchemeLess: () => string | null;
/**
* Returns the URL string without the protocol, composed of the hostname, pathname, search, and hash.
* It starts with a double slash.
*/
toProtocolLess: () => string | null;
parts: () => string[] | null;
};
47 changes: 36 additions & 11 deletions packages/url/dist/parsedUrl.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { normalize } from '@288-toolkit/strings';
import { decodePath } from './decodePath.js';
import { protocolLessUrl, schemeLessUrl } from './lessUrl.js';
import { normalizePath } from './normalizePath.js';
import { urlCanParse } from './urlCanParse.js';
/**
* Safely parses a URL and expose and nice API to access the parts of the URL.
* If the URL is not valid, all functions returns null.
*/
export const parsedUrl = (url) => {
const parsed = urlCanParse(url) ? new URL(url) : null;
const parsed = urlCanParse(url.toString()) ? new URL(url) : null;
const api = {
/**
* The URL object.
*/
parsed,
/**
* Checks if the URL is valid.
*/
valid: () => {
return parsed != null && parsed.toString() !== '';
},
/**
* Makes sure the pathname is properly encoded.
* This can be needed when the pathname contains special characters.
*
* @deprecated Pathname are always url encoded.
*/
encodePath: () => {
if (!parsed) {
Expand All @@ -25,15 +32,25 @@ export const parsedUrl = (url) => {
parsed.pathname = encodeURIComponent(parsed.pathname);
return api;
},
/**
* Decodes the pathname and returns it.
* It can't be stored in the URL object because it would be encoded again.
*/
decodePath: () => {
if (!parsed) {
return null;
}
return decodePath(parsed.pathname);
},
/**
* Normalizes the pathname by removing accents.
* @see {@link @288-toolkit/strings#normalize}
*/
normalizePath: () => {
if (!parsed) {
return null;
return api;
}
parsed.pathname = normalize(parsed.pathname);
parsed.pathname = normalizePath(parsed.pathname);
return api;
},
/**
Expand All @@ -51,31 +68,39 @@ export const parsedUrl = (url) => {
/**
* Returns the relative URL string.
* It starts with a single slash.
* @deprecated Relative URLs do not start with a single slash.
* They are relative to the current URL.
* Use `toSchemeLess()` instead.
*/
toRelative: () => {
return api.toSchemeLess();
},
/**
* Returns the URL string without the scheme, composed of the pathname, search, and hash.
* It starts with a single slash.
*/
toSchemeLess: () => {
if (!parsed) {
return null;
}
const { pathname, hash, search } = parsed;
return `${pathname}${search}${hash}`;
return schemeLessUrl(parsed);
},
/**
* Returns the URL string without the scheme, composed of the pathname, search, and hash.
* Returns the URL string without the protocol, composed of the hostname, pathname, search, and hash.
* It starts with a double slash.
*/
toSchemeLess: () => {
toProtocolLess: () => {
if (!parsed) {
return null;
}
const { hostname, pathname, hash, search } = parsed;
return `//${hostname}${pathname}${search}${hash}`;
return protocolLessUrl(parsed);
},
parts: () => {
if (!parsed) {
return null;
}
return parsed.pathname.split('/').filter(Boolean);
},
}
};
return api;
};
Loading

0 comments on commit 417de9c

Please sign in to comment.