Skip to content

Commit

Permalink
feature: support file url as webview root (#102)
Browse files Browse the repository at this point in the history
* feature: support file url as webview root

* coverage

* Merge remote-tracking branch 'origin/main' into feature/file

* coverage
  • Loading branch information
levivilet authored Dec 22, 2024
1 parent aa7098e commit 5f988c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@
"collectCoverage": true,
"coverageThreshold": {
"global": {
"branches": 50,
"branches": 47,
"functions": 43,
"lines": 61
"lines": 60
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { IncomingMessage, ServerResponse } from 'node:http'
import { fileURLToPath } from 'node:url'
import * as GetPathName from '../GetPathName/GetPathName.ts'
import * as GetResponse from '../GetResponse/GetResponse.ts'
import * as SendResponse from '../SendResponse/SendResponse.ts'
Expand All @@ -10,6 +11,9 @@ export const createHandler = (
contentSecurityPolicy: string,
iframeContent: string,
): any => {
if (webViewRoot && webViewRoot.startsWith('file://')) {
webViewRoot = fileURLToPath(webViewRoot)
}
const handleRequest = async (request: IncomingMessage, response: ServerResponse): Promise<void> => {
let pathName = GetPathName.getPathName(request)
if (pathName === '/') {
Expand Down

0 comments on commit 5f988c0

Please sign in to comment.