mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(cli): should proxy google social callback url properly to exp ui (#6458)
* fix(cli): should proxy google social callback url properly to exp ui * test(cli): add unit tests for tunnel util
This commit is contained in:
parent
e4b028847f
commit
57974a11d6
2 changed files with 26 additions and 2 deletions
20
packages/cli/src/commands/tunnel/utils.test.ts
Normal file
20
packages/cli/src/commands/tunnel/utils.test.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { expect, describe, it } from 'vitest';
|
||||
|
||||
import { isFileAssetPath } from './utils.js';
|
||||
|
||||
describe('Tunnel utils', () => {
|
||||
it('should be able to check if a request path is file asset', () => {
|
||||
expect(isFileAssetPath('/file.js')).toBe(true);
|
||||
expect(isFileAssetPath('/file.css')).toBe(true);
|
||||
expect(isFileAssetPath('/file.png')).toBe(true);
|
||||
expect(isFileAssetPath('/oidc/.well-known/openid-configuration')).toBe(false);
|
||||
expect(isFileAssetPath('/oidc/auth')).toBe(false);
|
||||
expect(isFileAssetPath('/api/interaction/submit')).toBe(false);
|
||||
expect(isFileAssetPath('/consent')).toBe(false);
|
||||
expect(
|
||||
isFileAssetPath(
|
||||
'/callback/45doq0d004awrjyvdbp92?state=PxsR_Iqtkxw&code=4/0AcvDMrCOMTFXWlKzTcUO24xDify5tQbIMYvaYDS0sj82NzzYlrG4BWXJB4-OxjBI1RPL8g&scope=email%20profile%20openid%20https:/www.googleapis.com/auth/userinfo.profile%20https:/www.googleapis.com/auth/userinfo.email&authuser=0&hd=silverhand.io&prompt=consent'
|
||||
)
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
|
@ -146,10 +146,14 @@ export const checkExperienceInput = (url?: string, staticPath?: string) => {
|
|||
* @example isLogtoRequestPath('/api/interaction/submit') // true
|
||||
* @example isLogtoRequestPath('/consent') // true
|
||||
*/
|
||||
export const isLogtoRequestPath = (requestPath?: string) =>
|
||||
export const isLogtoRequestPath = (requestPath?: string): boolean =>
|
||||
['/oidc/', '/api/'].some((path) => requestPath?.startsWith(path)) || requestPath === '/consent';
|
||||
|
||||
const isFileAssetPath = (url: string) => url.split('/').at(-1)?.includes('.');
|
||||
export const isFileAssetPath = (url: string): boolean => {
|
||||
// Check if the request URL contains query params. If yes, ignore the params and check the request path
|
||||
const pathWithoutQuery = url.split('?')[0];
|
||||
return Boolean(pathWithoutQuery?.split('/').at(-1)?.includes('.'));
|
||||
};
|
||||
|
||||
const getMimeType = (requestPath: string) => {
|
||||
const fallBackToIndex = !isFileAssetPath(requestPath);
|
||||
|
|
Loading…
Reference in a new issue