-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurl.go
More file actions
41 lines (31 loc) · 717 Bytes
/
url.go
File metadata and controls
41 lines (31 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"strings"
)
func fromUrl(ctx Context) {
res, ok := fetch(ctx)
if !ok {
return
}
contentType := res.Header.Get("Content-Type")
if contentType == "" {
Warn(ctx.Depth, "URL responded with no content type:", contentType)
return
}
// clean up text/html; charset=utf-8
contentType = strings.SplitN(contentType, ";", 2)[0]
switch contentType {
case "text/html":
fromHtml(ctx, res)
case "text/css":
fromCss(ctx, res)
case "application/javascript":
fromJs(ctx, res)
case "application/octet-stream":
fromSourceMap(ctx, res)
case "application/json":
fromSourceMap(ctx, res)
default:
Error(ctx.Depth, "URL responded with unknown content type:", contentType)
}
}