@ultirequiem/drive-link 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{types/mod.d.ts → lib/index.d.ts} +4 -3
- package/lib/index.d.ts.map +1 -0
- package/{esm/mod.js → lib/index.js} +3 -3
- package/package.json +36 -30
- package/readme.md +47 -0
- package/README.md +0 -72
- package/esm/package.json +0 -3
- package/script/mod.js +0 -48
- package/script/package.json +0 -3
- /package/{LICENSE → license} +0 -0
|
@@ -6,16 +6,17 @@ export interface DriveOptions {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
Generate a Google Drive direct download link based on the URL or ID.
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
@param URLorID The URL or ID of the drive content.
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
@example
|
|
13
13
|
```javascript
|
|
14
14
|
driveLink(
|
|
15
15
|
"https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
|
|
16
16
|
);
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
//=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
|
|
19
19
|
```
|
|
20
20
|
*/
|
|
21
21
|
export declare function driveLink(URLorID: string, { apiKey }?: DriveOptions): string;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,YAAY;IAC3B;;MAEE;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;EAaE;AACF,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,GAAE,YAAiB,UAgBvE"}
|
|
@@ -17,15 +17,15 @@ function extractId(urlOrId) {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
Generate a Google Drive direct download link based on the URL or ID.
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
@param URLorID The URL or ID of the drive content.
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
@example
|
|
24
24
|
```javascript
|
|
25
25
|
driveLink(
|
|
26
26
|
"https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
|
|
27
27
|
);
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
//=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
|
|
30
30
|
```
|
|
31
31
|
*/
|
package/package.json
CHANGED
|
@@ -1,39 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"module": "./esm/mod.js",
|
|
3
|
-
"main": "./script/mod.js",
|
|
4
|
-
"types": "./types/mod.d.ts",
|
|
5
2
|
"name": "@ultirequiem/drive-link",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"type": "patreon",
|
|
12
|
-
"url": "https://www.patreon.com/ultirequiem"
|
|
13
|
-
},
|
|
14
|
-
"repository": "github:ultirequiem/drive_link",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/ultirequiem/drive_link/issues",
|
|
17
|
-
"email": "eliaz.bobadilladev@gmail.com"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"drive",
|
|
21
|
-
"google"
|
|
22
|
-
],
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
23
8
|
"exports": {
|
|
24
9
|
".": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"types": "./types/mod.d.ts"
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"import": "./lib/index.js"
|
|
28
12
|
}
|
|
29
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib/**/*"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/UltiRequiem/drive_link.git"
|
|
25
|
+
},
|
|
30
26
|
"scripts": {
|
|
31
|
-
"
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"lint": "eslint 'src/**/*.ts' && prettier --check 'src/**/*.ts'",
|
|
29
|
+
"fmt": "prettier --write 'src/**/*.ts'",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:coverage": "vitest run --coverage"
|
|
32
32
|
},
|
|
33
|
-
"dependencies": {},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@types/node": "
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
"@types/node": "^26.6.5",
|
|
35
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
36
|
+
"eslint": "^10.13.0",
|
|
37
|
+
"eslint-plugin-tsdoc": "^0.5.4",
|
|
38
|
+
"eslint-plugin-unicorn": "^78.0.0",
|
|
39
|
+
"prettier": "^3.9.10",
|
|
40
|
+
"typescript": "^6.0.3",
|
|
41
|
+
"typescript-eslint": "^8.72.0",
|
|
42
|
+
"vitest": "^5.0.5"
|
|
43
|
+
},
|
|
44
|
+
"packageManager": "pnpm@12.6.0"
|
|
45
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Drive Link
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ultirequiem/drive-link)
|
|
4
|
+
[](https://www.npmjs.com/package/@ultirequiem/drive-link)
|
|
5
|
+
[](https://github.com/UltiRequiem/drive_link/actions/workflows/ci.yaml)
|
|
6
|
+
[](https://codecov.io/gh/UltiRequiem/drive_link)
|
|
7
|
+
|
|
8
|
+
Generate a [Google Drive](https://google.com/drive) direct download link based
|
|
9
|
+
on the URL or ID.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @ultirequiem/drive-link
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
ESM only, types included: the same import works in Node.js, Bun and browsers.
|
|
20
|
+
|
|
21
|
+
> Check [platforms](./platforms.md) for other runtime options.
|
|
22
|
+
|
|
23
|
+
## Support
|
|
24
|
+
|
|
25
|
+
Open an Issue, I will check it as soon as possible 👀
|
|
26
|
+
|
|
27
|
+
If you want to hurry me up a bit
|
|
28
|
+
[send me a tweet](https://twitter.com/UltiRequiem) 😆
|
|
29
|
+
|
|
30
|
+
Don't forget to star the repo ⭐
|
|
31
|
+
|
|
32
|
+
## Authors
|
|
33
|
+
|
|
34
|
+
[Eliaz Bobadilla](https://ultirequiem.com) - Creator and Maintainer 💪
|
|
35
|
+
|
|
36
|
+
See also the full list of
|
|
37
|
+
[contributors](https://github.com/UltiRequiem/drive_link/contributors) who
|
|
38
|
+
participated in this project ✨
|
|
39
|
+
|
|
40
|
+
## Versioning
|
|
41
|
+
|
|
42
|
+
We use [Semantic Versioning](http://semver.org). For the versions available, see
|
|
43
|
+
the [tags](https://github.com/UltiRequiem/drive_link/tags) 🏷️
|
|
44
|
+
|
|
45
|
+
## Licence
|
|
46
|
+
|
|
47
|
+
Licensed under the MIT License 📄
|
package/README.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Drive Link
|
|
2
|
-
|
|
3
|
-
[](https://codecov.io/gh/UltiRequiem/drive_link)
|
|
4
|
-
[](https://doc.deno.land/https/deno.land/x/drive_link/mod.ts)
|
|
5
|
-
|
|
6
|
-
Generate a [Google Drive](https://google.com/drive) direct download link based
|
|
7
|
-
on the URL or ID.
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
The API is the same on all this platforms ✔️
|
|
12
|
-
|
|
13
|
-
### [Deno 🦕](https://deno.land/x/drive_link)
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
16
|
-
import { driveLink } from "https://deno.land/x/drive_link/mod.ts";
|
|
17
|
-
|
|
18
|
-
driveLink(
|
|
19
|
-
"https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
|
|
20
|
-
);
|
|
21
|
-
//=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### [Node.js 🐢🚀](https://npmjs.com/package/@ultirequiem/drive-link)
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
import { driveLink } from "@ultirequiem/drive-link";
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### [Browser 🌐](https://developer.mozilla.org/en-US/docs/Glossary/Browser)
|
|
31
|
-
|
|
32
|
-
You can use any [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) 🔥
|
|
33
|
-
|
|
34
|
-
Eg 👉
|
|
35
|
-
[ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) ↔️
|
|
36
|
-
[SkyPack](https://cdn.skypack.dev/@ultirequiem/drive_link) 🆚
|
|
37
|
-
[Script Tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
|
|
38
|
-
↔️ [JSDelivr](https://cdn.jsdelivr.net/npm/@ultirequiem/drive_link)
|
|
39
|
-
|
|
40
|
-
## Documentation
|
|
41
|
-
|
|
42
|
-
Is hosted on
|
|
43
|
-
[Deno Doc](https://doc.deno.land/https://deno.land/x/drive_link/mod.ts) 📄
|
|
44
|
-
|
|
45
|
-
## Support
|
|
46
|
-
|
|
47
|
-
Open an Issue, I will check it a soon as possible 👀
|
|
48
|
-
|
|
49
|
-
If you want to hurry me up a bit
|
|
50
|
-
[send me a tweet](https://twitter.com/UltiRequiem) 😆
|
|
51
|
-
|
|
52
|
-
Consider [supporting me on Patreon](https://patreon.com/UltiRequiem) if you like
|
|
53
|
-
my work 🙏
|
|
54
|
-
|
|
55
|
-
Don't forget to start the repo ⭐
|
|
56
|
-
|
|
57
|
-
## Authors
|
|
58
|
-
|
|
59
|
-
[Eliaz Bobadilla](https://ultirequiem.com) - Creator and Maintainer 💪
|
|
60
|
-
|
|
61
|
-
See also the full list of
|
|
62
|
-
[contributors](https://github.com/UltiRequiem/drive_link/contributors) who
|
|
63
|
-
participated in this project ✨
|
|
64
|
-
|
|
65
|
-
## Versioning
|
|
66
|
-
|
|
67
|
-
We use [Semantic Versioning](http://semver.org). For the versions available, see
|
|
68
|
-
the [tags](https://github.com/UltiRequiem/drive_link/tags) 🏷️
|
|
69
|
-
|
|
70
|
-
## Licence
|
|
71
|
-
|
|
72
|
-
Licensed under the MIT License 📄
|
package/esm/package.json
DELETED
package/script/mod.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.driveLink = void 0;
|
|
4
|
-
const formatRegexes = [
|
|
5
|
-
/https:\/\/drive\.google\.com\/file\/d\/(?<id>.*?)\/(?:edit|view)\?usp=sharing/,
|
|
6
|
-
/https:\/\/drive\.google\.com\/open\?id=(?<id>.*?)$/,
|
|
7
|
-
];
|
|
8
|
-
const alphanumericRegex = /^[\w-]+$/;
|
|
9
|
-
function extractId(urlOrId) {
|
|
10
|
-
for (const format of formatRegexes) {
|
|
11
|
-
if (format.test(urlOrId)) {
|
|
12
|
-
const result = format.exec(urlOrId);
|
|
13
|
-
return result?.groups?.id;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (alphanumericRegex.test(urlOrId)) {
|
|
17
|
-
return urlOrId;
|
|
18
|
-
}
|
|
19
|
-
throw new Error("Invalid URL provided.");
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
Generate a Google Drive direct download link based on the URL or ID.
|
|
23
|
-
|
|
24
|
-
@param URLorID The URL or ID of the drive content.
|
|
25
|
-
|
|
26
|
-
@example
|
|
27
|
-
```javascript
|
|
28
|
-
driveLink(
|
|
29
|
-
"https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
//=> "https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"
|
|
33
|
-
```
|
|
34
|
-
*/
|
|
35
|
-
function driveLink(URLorID, { apiKey } = {}) {
|
|
36
|
-
if (typeof URLorID !== "string") {
|
|
37
|
-
throw new TypeError("Invalid URL provided.");
|
|
38
|
-
}
|
|
39
|
-
if (typeof apiKey === "string" && !alphanumericRegex.test(apiKey)) {
|
|
40
|
-
throw new TypeError("Invalid API key provided.");
|
|
41
|
-
}
|
|
42
|
-
const id = extractId(URLorID.trim());
|
|
43
|
-
const parsedKey = apiKey?.trim();
|
|
44
|
-
return parsedKey
|
|
45
|
-
? `https://www.googleapis.com/drive/v3/files/${id}?alt=media&key=${parsedKey}`
|
|
46
|
-
: `https://drive.google.com/uc?export=download&id=${id}`;
|
|
47
|
-
}
|
|
48
|
-
exports.driveLink = driveLink;
|
package/script/package.json
DELETED
/package/{LICENSE → license}
RENAMED
|
File without changes
|