MCPcopy
hub / github.com/baidu/amis / isValidApi

Function isValidApi

packages/amis-core/src/utils/api.ts:912–931  ·  view source on GitHub ↗
(api: string)

Source from the content-addressed store, hash-verified

910}
911
912export function isValidApi(api: string) {
913 if (!api || typeof api !== 'string') {
914 return false;
915 }
916 const idx = api.indexOf('://');
917
918 // 不允许 :// 结尾
919 if (~idx && idx + 3 === api.length) {
920 return false;
921 }
922
923 try {
924 // 不补一个协议,URL 判断为 false
925 api = (~idx ? '' : `schema://domain${api[0] === '/' ? '' : '/'}`) + api;
926 new URL(api);
927 } catch (error) {
928 return false;
929 }
930 return true;
931}
932
933export function isEffectiveApi(
934 api?: Api,

Callers 5

componentDidUpdateMethod · 0.90
api.test.tsFile · 0.90
renderFooterMethod · 0.90
wrappedFetcherFunction · 0.85
isApiOutdatedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected