This commit is contained in:
unfunny
2026-09-12 23:57:45 -04:00
parent 986c0af682
commit dfe4cc537f
1775 changed files with 246421 additions and 0 deletions

View File

@@ -0,0 +1 @@
export declare function isValidUrl(val: string): boolean;

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isValidUrl = isValidUrl;
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function isValidUrl(val) {
if (!val) return false; // easy: not valid if not present
try {
var parsed = new URL(val);
if (parsed.protocol !== "http" && parsed.protocol !== "https") {
return false;
}
return true;
} catch (e) {
if (e instanceof TypeError) {
return false;
}
throw e;
}
}
//# sourceMappingURL=url.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"url.js","names":["isValidUrl","val","parsed","URL","protocol","e","TypeError"],"sources":["../../../src/models/validation/url.ts"],"sourcesContent":["/*\n * Copyright 2020 The Matrix.org Foundation C.I.C.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function isValidUrl(val: string): boolean {\n if (!val) return false; // easy: not valid if not present\n\n try {\n const parsed = new URL(val);\n if (parsed.protocol !== \"http\" && parsed.protocol !== \"https\") {\n return false;\n }\n return true;\n } catch (e) {\n if (e instanceof TypeError) {\n return false;\n }\n throw e;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,SAASA,UAAUA,CAACC,GAAW,EAAW;EAC7C,IAAI,CAACA,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC;;EAExB,IAAI;IACA,IAAMC,MAAM,GAAG,IAAIC,GAAG,CAACF,GAAG,CAAC;IAC3B,IAAIC,MAAM,CAACE,QAAQ,KAAK,MAAM,IAAIF,MAAM,CAACE,QAAQ,KAAK,OAAO,EAAE;MAC3D,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf,CAAC,CAAC,OAAOC,CAAC,EAAE;IACR,IAAIA,CAAC,YAAYC,SAAS,EAAE;MACxB,OAAO,KAAK;IAChB;IACA,MAAMD,CAAC;EACX;AACJ","ignoreList":[]}

View File

@@ -0,0 +1 @@
export declare function assertPresent<O extends Record<any, any>>(obj: O, key: keyof O): void;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.assertPresent = assertPresent;
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function assertPresent(obj, key) {
if (!obj[key]) {
throw new Error("".concat(String(key), " is required"));
}
}
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","names":["assertPresent","obj","key","Error","concat","String"],"sources":["../../../src/models/validation/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 The Matrix.org Foundation C.I.C.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function assertPresent<O extends Record<any, any>>(obj: O, key: keyof O): void {\n if (!obj[key]) {\n throw new Error(`${String(key)} is required`);\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO,SAASA,aAAaA,CAA6BC,GAAM,EAAEC,GAAY,EAAQ;EAClF,IAAI,CAACD,GAAG,CAACC,GAAG,CAAC,EAAE;IACX,MAAM,IAAIC,KAAK,IAAAC,MAAA,CAAIC,MAAM,CAACH,GAAG,CAAC,iBAAc,CAAC;EACjD;AACJ","ignoreList":[]}