@@ -21,11 +21,13 @@ import { getExecutablePath, validateUrl } from './utils'
2121 * @type {object }
2222 * @property {boolean } dump - Export fetched output as string
2323 * @property {boolean } disableHostVerification - Disables host verification on all HTTP requests
24+ * @property {boolean } obeyRobots - Fetches and obeys the robots.txt (if available) of the web pages we make requests towards.
2425 * @property {string } httpProxy - The HTTP proxy to use for all HTTP requests
2526 */
2627export type LightpandaFetchOptions = {
2728 dump ?: boolean
2829 disableHostVerification ?: boolean
30+ obeyRobots ?: boolean
2931 httpProxy ?: string
3032}
3133
@@ -40,7 +42,7 @@ const defaultOptions: LightpandaFetchOptions = {
4042 * @returns {Promise<Buffer | string> }
4143 */
4244export const fetch = ( url : string , options : LightpandaFetchOptions = defaultOptions ) => {
43- const { dump, disableHostVerification, httpProxy } = options
45+ const { dump, disableHostVerification, obeyRobots , httpProxy } = options
4446 validateUrl ( url )
4547
4648 if ( httpProxy ) {
@@ -53,6 +55,7 @@ export const fetch = (url: string, options: LightpandaFetchOptions = defaultOpti
5355 const flags = [
5456 { flag : '--dump' , condition : dump } ,
5557 { flag : '--insecure_disable_tls_host_verification' , condition : disableHostVerification } ,
58+ { flag : '--obey_robots' , condition : obeyRobots } ,
5659 { flag : `--http_proxy ${ httpProxy } ` , condition : httpProxy } ,
5760 ]
5861 . map ( f => ( f . condition ? f . flag : '' ) )
0 commit comments