зеркало из https://github.com/microsoft/mouselog.git
Re-escape the screenshot URL.
This commit is contained in:
Родитель
878784c7a3
Коммит
04a694c81c
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func TransparentStatic(ctx *context.Context) {
|
||||
urlPath := ctx.Request.URL.Path
|
||||
if strings.HasPrefix(urlPath, "/api/") {
|
||||
if strings.HasPrefix(urlPath, "/api/") || strings.HasPrefix(urlPath, "/screenshots/") {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -91,12 +91,12 @@ func DeletePage(id string) bool {
|
|||
func (p *Page) takeScreenshot() {
|
||||
website := GetWebsite(p.WebsiteId)
|
||||
screenshotUrl := util.JoinUrl(website.Url, p.UrlPath)
|
||||
escapedPageId := url.QueryEscape(p.Id)
|
||||
screenshotId := url.PathEscape(p.Id)
|
||||
|
||||
filePathName := util.GetScreenshotPath(p.WebsiteId, escapedPageId)
|
||||
filePathName := util.GetScreenshotPath(p.WebsiteId, screenshotId)
|
||||
util.EnsureFileFolderExists(filePathName)
|
||||
screenshot.TakeScreenshot(screenshotUrl, filePathName)
|
||||
|
||||
p.ScreenshotUrl = util.GetScreenshotUrl(p.WebsiteId, escapedPageId)
|
||||
p.ScreenshotUrl = util.GetScreenshotUrl(p.WebsiteId, url.PathEscape(screenshotId))
|
||||
UpdatePage(p.Id, p)
|
||||
}
|
||||
|
|
|
@ -13,10 +13,11 @@ func GetCsvDataPath(fileId string) string {
|
|||
return CacheDir + "mouselog/" + fileId + ".csv"
|
||||
}
|
||||
|
||||
func GetScreenshotPath(websiteId string, escapedPageId string) string {
|
||||
return fmt.Sprintf("../static/screenshots/%s/%s.png", websiteId, escapedPageId)
|
||||
func GetScreenshotPath(websiteId string, screenshotId string) string {
|
||||
return fmt.Sprintf("../static/screenshots/%s/%s.png", websiteId, screenshotId)
|
||||
}
|
||||
|
||||
func GetScreenshotUrl(websiteId string, escapedPageId string) string {
|
||||
return fmt.Sprintf("https://mouselog.org/screenshots/%s/%s.png", websiteId, escapedPageId)
|
||||
func GetScreenshotUrl(websiteId string, screenshotId string) string {
|
||||
return fmt.Sprintf("https://mouselog.org/screenshots/%s/%s.png", websiteId, screenshotId)
|
||||
//return fmt.Sprintf("http://localhost:9000/screenshots/%s/%s.png", websiteId, screenshotId)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче