// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { isWindows } from "./_os.ts";
import { relative as posixRelative } from "./posix/relative.ts";
import { relative as windowsRelative } from "./windows/relative.ts";

/**
 * Return the relative path from `from` to `to` based on current working directory.
 *
 * An example in windws, for instance:
 *  from = 'C:\\orandea\\test\\aaa'
 *  to = 'C:\\orandea\\impl\\bbb'
 * The output of the function should be: '..\\..\\impl\\bbb'
 *
 * @param from path in current working directory
 * @param to path in current working directory
 */
export function relative(from: string, to: string): string {
  return isWindows ? windowsRelative(from, to) : posixRelative(from, to);
}

// denoCacheMetadata={"headers":{"cf-ray":"a223e6579a207db6-LAX","vary":"Origin","cache-control":"public, max-age=31536000, immutable","x-jsr-backend":"modules","date":"Tue, 28 Jul 2026 12:31:15 GMT","cross-origin-resource-policy":"cross-origin","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=8amo6vgdZaLj5%2B3b7t83REWEMs8tBZOdolZMzlu3RUnj8DVk49ts6WGgJZiPXg6AUUA12701JLe%2BBUPVEMwe2WMsPwmRMHoOzVRhNdRPJI2HjBPtI87StsY%3D\"}]}","alt-svc":"h3=\":443\"; ma=86400","age":"44352","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","content-length":"788","content-type":"text/typescript","accept-ranges":"bytes","access-control-allow-origin":"*","x-content-type-options":"nosniff","cf-cache-status":"HIT","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","server":"cloudflare","access-control-expose-headers":"*","x-robots-tag":"noindex","etag":"\"0735763219b351c3520264c14dcdb50e\"","set-cookie":"__cf_bm=PfeTkBGcFGkKj__oSvkNAngOWO1_BIGALY3ded8TFyE-1785241875.1416202-1.0.1.1-HW6tZFyoWs5OnW3WhtL_tRqzJAQj_q8MDEjxmS_moeCFsl4EvIa2FwmkITVLlAa4o1uDMaIadF3D3ePjVCqibG.EzvrLDd7fSUfrgflxelmMmaa.58ADKOGy.gCqO.aP; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT"},"url":"https://jsr.io/@std/path/0.224.0/relative.ts","time":1785241875}