Path: blob/master/src/packages/next/lib/share/raw-url.ts
1449 views
/*1The raw URL is the following, of course encoded as a URL:23.../raw/{share id}/{the full path in the project to file}4*/56import { join } from "path";7import basePath from "lib/base-path";89interface Options {10id: string;11path: string;12relativePath: string;13}1415export default function rawURL({ id, path, relativePath }: Options): string {16return join(17basePath,18`share/raw/${id}/${encodePath(join(path, relativePath))}`19);20}2122export function encodePath(path: string) {23const segments = path.split("/");24const encoded: string[] = [];25for (const segment of segments) {26encoded.push(encodeURIComponent(segment));27}28return encoded.join("/");29}303132