UNPKG

bugyo-cloud-client

Version:
26 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseToken = void 0; const cheerio_1 = require("cheerio"); const bugyo_cloud_client_1 = require("../bugyo-cloud-client"); /** * ページ中にある__RequestVerificationTokenを返します。 * @param html HTML */ const parseToken = (html) => { const $ = (0, cheerio_1.load)(html); const ele = $("input[name=__RequestVerificationToken]"); if (ele.length === 0) { new bugyo_cloud_client_1.BugyoCloudClientError("Cannot find a element of __RequestVerificationToken."); } const val = ele.val(); if (val === undefined) { throw new bugyo_cloud_client_1.BugyoCloudClientError("Cannot get a value attribute of the __RequestVerificationToken."); } if (Array.isArray(val)) { throw new bugyo_cloud_client_1.BugyoCloudClientError("Too many __RequestVerificationToken input fields. "); } return val; }; exports.parseToken = parseToken; //# sourceMappingURL=page-token-parser.js.map