- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
/**
|
||
* Checks if a value has the shape of a WHATWG URL object.
|
||
*
|
||
* Using a symbol or instanceof would not be able to recognize URL objects
|
||
* coming from other implementations (e.g. in Electron), so instead we are
|
||
* checking some well known properties for a lack of a better test.
|
||
*
|
||
* We use `href` and `protocol` as they are the only properties that are
|
||
* easy to retrieve and calculate due to the lazy nature of the getters.
|
||
*
|
||
* We check for auth attribute to distinguish legacy url instance with
|
||
* WHATWG URL instance.
|
||
*
|
||
* @param {unknown} fileUrlOrPath
|
||
* File path or URL.
|
||
* @returns {fileUrlOrPath is URL}
|
||
* Whether it’s a URL.
|
||
*/
|
||
// From: <https://github.com/nodejs/node/blob/6a3403c/lib/internal/url.js#L720>
|
||
export function isUrl(fileUrlOrPath) {
|
||
return Boolean(
|
||
fileUrlOrPath !== null &&
|
||
typeof fileUrlOrPath === 'object' &&
|
||
'href' in fileUrlOrPath &&
|
||
fileUrlOrPath.href &&
|
||
'protocol' in fileUrlOrPath &&
|
||
fileUrlOrPath.protocol &&
|
||
// @ts-expect-error: indexing is fine.
|
||
fileUrlOrPath.auth === undefined
|
||
)
|
||
}
|