项目作者: dBrowser

项目描述 :
Internal dBrowser module for working with legacy dWeb paths.
高级语言: JavaScript
项目地址: git://github.com/dBrowser/dwebx-serve-resolve-path.git
创建时间: 2020-08-23T12:06:56Z
项目社区:https://github.com/dBrowser/dwebx-serve-resolve-path

开源协议:

下载


dwebx-serve-resolve-path

dBrowser’s method to find the file to serve in dwebx:// requests

  1. const dwebxServeResolvePath = require('@dbrowser/dwebx-serve-resolve-path')
  2. var entry = await dwebxServeResolvePath(archive, manifest, url, acceptHeader)
  3. console.log(entry) /* => {
  4. path: '...',
  5. isDirectory(),
  6. isFile(),
  7. ...
  8. }

Pass in:

  • archive The DWebXArchive to read from.
  • manifest The dwebx archive’s dwebx.json manifest (optional)
  • url The request URL (can be pre-parsed by parse-dwebx-urls). If passing the URL, include the FULL url (hostname too).
  • acceptHeader The request Accept header.

Returns a Stat object with the .path string added. Will return null if no matching file is found.

In the browser

Run npm run build to output dist.js. This bundle will set window.dwebxServeResolvePath() when included.