{"record":{"id":"189bcf99a1095dde","repo":"jackwener/OpenCLI","slug":"invalid-quark-share-url-url","errorCode":null,"errorMessage":"Invalid Quark share URL: ${url}","messagePattern":"Invalid Quark share URL: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/quark/utils.js","lineNumber":32,"sourceCode":"        return undefined;\n    const status = error.status;\n    return typeof status === 'number' ? status : undefined;\n}\nfunction unwrapApiData(resp, action) {\n    if (resp.status === 200)\n        return resp.data;\n    if (isAuthFailure(resp.message, resp.status)) {\n        throw new AuthRequiredError(QUARK_DOMAIN, AUTH_HINT);\n    }\n    throw new CommandExecutionError(`quark: ${action}: ${resp.message}`);\n}\nexport function extractPwdId(url) {\n    const m = url.match(/\\/s\\/([a-zA-Z0-9]+)/);\n    if (m)\n        return m[1];\n    if (/^[a-zA-Z0-9]+$/.test(url))\n        return url;\n    throw new ArgumentError(`Invalid Quark share URL: ${url}`);\n}\nexport async function fetchJson(page, url, options) {\n    const method = options?.method || 'GET';\n    const body = options?.body ? JSON.stringify(options.body) : undefined;\n    const js = `fetch(${JSON.stringify(url)}, {\n    method: ${JSON.stringify(method)},\n    headers: { 'Content-Type': 'application/json' },\n    credentials: 'include',\n    ${body ? `body: ${JSON.stringify(body)},` : ''}\n  }).then(async r => {\n    const ct = r.headers.get('content-type') || '';\n    if (!ct.includes('json')) {\n      const text = await r.text().catch(() => '');\n      throw Object.assign(new Error('Non-JSON response: ' + text.slice(0, 200)), { status: r.status });\n    }\n    return r.json();\n  })`;\n    try {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/utils.js#L14-L50","documentation":"extractPwdId in clis/quark/utils.js throws ArgumentError when the given share URL matches neither the /s/<id> path pattern nor a bare alphanumeric pwd id. This value (pwd_id) is required for all share operations (getToken, saveShare), so the command fails fast before any API call.","triggerScenarios":"Passing a full HTML page URL with extra query/hash that the regex still fails on (e.g. different domain path), a wrapped/redirector URL, a URL with percent-encoded or malformed share id, or pasting a title/description instead of the link.","commonSituations":"Copying a share link from an app that emits short/redirect URLs; including surrounding markdown or quotes around the URL; Quark changing its share URL format; passing a share code with punctuation or hyphens.","solutions":["Pass the canonical share URL of the form https://pan.quark.cn/s/<alnum-id>.","Alternatively pass just the bare alphanumeric share id (e.g. abc123def).","Trim surrounding quotes, whitespace, or markdown from the pasted URL.","Resolve redirector/short links to the final pan.quark.cn/s/... URL before invoking.","If Quark changed URL format, update the extractPwdId regex accordingly."],"exampleFix":"// before\nconst pwdId = extractPwdId('\"https://pan.quark.cn/s/abc123\"'); // quotes included\n// after\nconst url = raw.trim().replace(/^[\"'<]|[\"'>]$/g, '');\nconst pwdId = extractPwdId(url);","handlingStrategy":"validation","validationCode":"function normalizeShareUrl(raw) {\n  const s = String(raw || '').trim().replace(/[\"'<>/]/g, m => m === '/' ? '/' : '');\n  const m = s.match(/pan\\.quark\\.cn\\/s\\/([a-zA-Z0-9]+)/);\n  if (!m && !/^[a-zA-Z0-9]+$/.test(s)) {\n    throw new Error(`Not a valid Quark share link or id: ${raw}`);\n  }\n  return m ? m[1] : s;\n}","typeGuard":"function isQuarkShareUrl(u) {\n  return typeof u === 'string' &&\n    (/pan\\.quark\\.cn\\/s\\/[a-zA-Z0-9]+/.test(u) || /^[a-zA-Z0-9]+$/.test(u.trim()));\n}","tryCatchPattern":null,"preventionTips":["Trim quotes/markdown from pasted share links before use.","Resolve short/redirect links to the canonical pan.quark.cn/s/... form.","Validate the URL matches the /s/<alnum> pattern in scripts before invoking save."],"tags":["validation","argument-error","url-parsing","quark"],"backgroundTag":"invalid-url-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}