@ossintel/input-parser 0.1.0 → 0.2.1
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -47,6 +47,6 @@ interface InputDetectionResult {
|
|
|
47
47
|
* // => { platform: "npm", type: "package", name: "kosha", rawInput: "npm:kosha" }
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
declare
|
|
50
|
+
declare const detectInput: (input: string) => InputDetectionResult;
|
|
51
51
|
|
|
52
52
|
export { type InputDetectionResult, detectInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,6 @@ interface InputDetectionResult {
|
|
|
47
47
|
* // => { platform: "npm", type: "package", name: "kosha", rawInput: "npm:kosha" }
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
declare
|
|
50
|
+
declare const detectInput: (input: string) => InputDetectionResult;
|
|
51
51
|
|
|
52
52
|
export { type InputDetectionResult, detectInput };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(n,t)=>{for(var r in t)a(n,r,{get:t[r],enumerable:!0})},f=(n,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of u(t))!l.call(n,e)&&e!==r&&a(n,e,{get:()=>t[e],enumerable:!(p=o(t,e))||p.enumerable});return n};var c=n=>f(a({},"__esModule",{value:!0}),n);var I={};m(I,{detectInput:()=>h});module.exports=c(I);var h=n=>{let t=n.trim();if(t.startsWith("npm:pkg:"))return{platform:"npm",type:"package",name:t.slice(8),rawInput:t};if(t.startsWith("npm:")){let r=t.slice(4);return r.startsWith("~")?{platform:"npm",type:"user",name:r.slice(1),rawInput:t}:{platform:"npm",type:"package",name:r,rawInput:t}}if(t.startsWith("~"))return{platform:"npm",type:"user",name:t.slice(1),rawInput:t};if(t.startsWith("so:")||t.startsWith("stackoverflow:")){let r=t.startsWith("so:")?3:14;return{platform:"stackoverflow",type:"user",profileId:t.slice(r),rawInput:t}}if(t.startsWith("org:")||t.startsWith("github:org:")){let r=t.startsWith("org:")?4:11;return{platform:"github",type:"org",owner:t.slice(r),rawInput:t}}if(t.startsWith("user:")||t.startsWith("github:user:")){let r=t.startsWith("user:")?5:12;return{platform:"github",type:"user",owner:t.slice(r),rawInput:t}}if(t.startsWith("github:repo:")){let r=t.slice(12).split("/");return{platform:"github",type:"repo",owner:r[0]||"",repo:r[1]||"",rawInput:t}}if(t.startsWith("github:")){let r=t.slice(7).split("/");return r.length>=2?{platform:"github",type:"repo",owner:r[0],repo:r[1],rawInput:t}:{platform:"github",type:"unknown",owner:r[0],rawInput:t}}if(t.startsWith("vscode:")){let r=t.slice(7).split("/");return{platform:"vscode",type:r.length>=2?"package":"user",name:r.join("."),rawInput:t}}if(t.startsWith("medium:"))return{platform:"medium",type:"user",profileId:t.slice(7),rawInput:t};if(t.startsWith("leetcode:"))return{platform:"leetcode",type:"user",profileId:t.slice(9),rawInput:t};try{let r=new URL(t.match(/^https?:\/\//i)?t:`https://${t}`),p=r.hostname.toLowerCase();if(p.includes("github.com")){let e=r.pathname.split("/").filter(Boolean);if(e[0]==="organizations"||e[0]==="orgs")return{platform:"github",type:"org",owner:e[1]||"",rawInput:t};if(e.length===1)return{platform:"github",type:"unknown",owner:e[0],rawInput:t};if(e.length>=2)return{platform:"github",type:"repo",owner:e[0],repo:e[1],rawInput:t}}if(p.includes("npmjs.com")){let e=r.pathname.split("/").filter(Boolean);if(e[0]==="package")return{platform:"npm",type:"package",name:e.slice(1).join("/"),rawInput:t};if(e[0].startsWith("~"))return{platform:"npm",type:"user",name:e[0].slice(1),rawInput:t};if(e[0].startsWith("@"))return e.length===1?{platform:"npm",type:"org",name:e[0],rawInput:t}:{platform:"npm",type:"package",name:`${e[0]}/${e[1]}`,rawInput:t}}if(p.includes("stackoverflow.com")){let e=r.pathname.split("/").filter(Boolean);if(e[0]==="users"&&e[1])return{platform:"stackoverflow",type:"user",profileId:e[1],name:e[2]||void 0,rawInput:t}}if(p.includes("medium.com")){let e=r.pathname.split("/").filter(Boolean),i=e[0]?.startsWith("@")?e[0].slice(1):e[0];if(i)return{platform:"medium",type:"user",profileId:i,rawInput:t}}}catch{}if(t.startsWith("organizations/")||t.startsWith("orgs/"))return{platform:"github",type:"org",owner:t.split("/")[1]||"",rawInput:t};if(t.startsWith("@")&&t.includes("/"))return{platform:"npm",type:"package",name:t,rawInput:t};if(t.includes("/")){let r=t.split("/");return{platform:"github",type:"repo",owner:r[0],repo:r[1],rawInput:t}}return{platform:"github",type:"unknown",owner:t,rawInput:t}};0&&(module.exports={detectInput});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var y=a=>{let t=a.trim();if(t.startsWith("npm:pkg:"))return{platform:"npm",type:"package",name:t.slice(8),rawInput:t};if(t.startsWith("npm:")){let r=t.slice(4);return r.startsWith("~")?{platform:"npm",type:"user",name:r.slice(1),rawInput:t}:{platform:"npm",type:"package",name:r,rawInput:t}}if(t.startsWith("~"))return{platform:"npm",type:"user",name:t.slice(1),rawInput:t};if(t.startsWith("so:")||t.startsWith("stackoverflow:")){let r=t.startsWith("so:")?3:14;return{platform:"stackoverflow",type:"user",profileId:t.slice(r),rawInput:t}}if(t.startsWith("org:")||t.startsWith("github:org:")){let r=t.startsWith("org:")?4:11;return{platform:"github",type:"org",owner:t.slice(r),rawInput:t}}if(t.startsWith("user:")||t.startsWith("github:user:")){let r=t.startsWith("user:")?5:12;return{platform:"github",type:"user",owner:t.slice(r),rawInput:t}}if(t.startsWith("github:repo:")){let r=t.slice(12).split("/");return{platform:"github",type:"repo",owner:r[0]||"",repo:r[1]||"",rawInput:t}}if(t.startsWith("github:")){let r=t.slice(7).split("/");return r.length>=2?{platform:"github",type:"repo",owner:r[0],repo:r[1],rawInput:t}:{platform:"github",type:"unknown",owner:r[0],rawInput:t}}if(t.startsWith("vscode:")){let r=t.slice(7).split("/");return{platform:"vscode",type:r.length>=2?"package":"user",name:r.join("."),rawInput:t}}if(t.startsWith("medium:"))return{platform:"medium",type:"user",profileId:t.slice(7),rawInput:t};if(t.startsWith("leetcode:"))return{platform:"leetcode",type:"user",profileId:t.slice(9),rawInput:t};try{let r=new URL(t.match(/^https?:\/\//i)?t:`https://${t}`),n=r.hostname.toLowerCase();if(n.includes("github.com")){let e=r.pathname.split("/").filter(Boolean);if(e[0]==="organizations"||e[0]==="orgs")return{platform:"github",type:"org",owner:e[1]||"",rawInput:t};if(e.length===1)return{platform:"github",type:"unknown",owner:e[0],rawInput:t};if(e.length>=2)return{platform:"github",type:"repo",owner:e[0],repo:e[1],rawInput:t}}if(n.includes("npmjs.com")){let e=r.pathname.split("/").filter(Boolean);if(e[0]==="package")return{platform:"npm",type:"package",name:e.slice(1).join("/"),rawInput:t};if(e[0].startsWith("~"))return{platform:"npm",type:"user",name:e[0].slice(1),rawInput:t};if(e[0].startsWith("@"))return e.length===1?{platform:"npm",type:"org",name:e[0],rawInput:t}:{platform:"npm",type:"package",name:`${e[0]}/${e[1]}`,rawInput:t}}if(n.includes("stackoverflow.com")){let e=r.pathname.split("/").filter(Boolean);if(e[0]==="users"&&e[1])return{platform:"stackoverflow",type:"user",profileId:e[1],name:e[2]||void 0,rawInput:t}}if(n.includes("medium.com")){let e=r.pathname.split("/").filter(Boolean),s=e[0]?.startsWith("@")?e[0].slice(1):e[0];if(s)return{platform:"medium",type:"user",profileId:s,rawInput:t}}}catch{}if(t.startsWith("organizations/")||t.startsWith("orgs/"))return{platform:"github",type:"org",owner:t.split("/")[1]||"",rawInput:t};if(t.startsWith("@")&&t.includes("/"))return{platform:"npm",type:"package",name:t,rawInput:t};if(t.includes("/")){let r=t.split("/");return{platform:"github",type:"repo",owner:r[0],repo:r[1],rawInput:t}}return{platform:"github",type:"unknown",owner:t,rawInput:t}};export{y as detectInput};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@ossintel/input-parser",
|
|
3
3
|
"author": "Mayank Kumar Chaudhari <https://mayankchaudhari.com>",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1
|
|
5
|
+
"version": "0.2.1",
|
|
6
6
|
"description": "Lightweight and extensible input query parser for resolving developer, repository, organization, and package paths across multiple ecosystems (GitHub, NPM, StackOverflow, VS Code).",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "./dist/index.js",
|