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

import { _common } from "./_common/common.ts";
import { SEPARATOR } from "./constants.ts";

/** Determines the common path from a set of paths, using an optional separator,
 * which defaults to the OS default separator.
 *
 * ```ts
 *       import { common } from "@std/path";
 *       const p = common([
 *         "./deno/std/path/mod.ts",
 *         "./deno/std/fs/mod.ts",
 *       ]);
 *       console.log(p); // "./deno/std/"
 * ```
 */
export function common(
  paths: string[],
  sep: string = SEPARATOR,
): string {
  return _common(paths, sep);
}

// denoCacheMetadata={"headers":{"content-length":"671","x-content-type-options":"nosniff","date":"Tue, 28 Jul 2026 12:31:15 GMT","set-cookie":"__cf_bm=jnzTxx8XAyGOXLwS9dekEMdrZuVidQ3YjP9meaLdeWQ-1785241875.151921-1.0.1.1-Avqh5KMThCeC0Y0GLKbkIHeHAaWPGnBWctbmnkQgXQc4ZBAemWaLFZHZAJoiPvIPKrI2SkoltBELuZ9dv2w_OuPuo.A36HUJrs26q0HyKxCpeJfD93NAluMRti1UBV5X; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","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';","etag":"\"97f7a6caba4ef26198e4ef93bd8eb6d1\"","cache-control":"public, max-age=31536000, immutable","vary":"Origin","age":"4020017","accept-ranges":"bytes","access-control-allow-origin":"*","x-robots-tag":"noindex","access-control-expose-headers":"*","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=GLP%2BwjxCNrs7D0HXnYpfgSfILhVYGbIOuE0sDl4rCSfe1LqzdoBhsXiM5HFYNY%2FUqok5cs0TiUmDCe3SaF5GQkLHRh7XI9LZfD%2B%2FUAImuQmMes6W05kNywY%3D\"}]}","cf-ray":"a223e657ba437db6-LAX","server":"cloudflare","alt-svc":"h3=\":443\"; ma=86400","x-jsr-backend":"modules","cf-cache-status":"HIT","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","cross-origin-resource-policy":"cross-origin","content-type":"text/typescript"},"url":"https://jsr.io/@std/path/0.224.0/common.ts","time":1785241875}