How to use Rel method of html Package

Best K6 code snippet using html.Rel

subpath_test.go

Source:subpath_test.go Github

copy

Full Screen

1package utils_test2import (3 "fmt"4 "io/ioutil"5 "os"6 "path/filepath"7 "strings"8 "testing"9 "github.com/stretchr/testify/require"10 "github.com/mattermost/mattermost-server/model"11 "github.com/mattermost/mattermost-server/utils"12)13func TestUpdateAssetsSubpath(t *testing.T) {14 t.Run("no client dir", func(t *testing.T) {15 tempDir, err := ioutil.TempDir("", "test_update_assets_subpath")16 require.NoError(t, err)17 defer os.RemoveAll(tempDir)18 os.Chdir(tempDir)19 err = utils.UpdateAssetsSubpath("/")20 require.Error(t, err)21 })22 t.Run("valid", func(t *testing.T) {23 tempDir, err := ioutil.TempDir("", "test_update_assets_subpath")24 require.NoError(t, err)25 defer os.RemoveAll(tempDir)26 os.Chdir(tempDir)27 err = os.Mkdir(model.CLIENT_DIR, 0700)28 require.NoError(t, err)29 testCases := []struct {30 Description string31 RootHTML string32 MainCSS string33 ManifestJSON string34 Subpath string35 ExpectedError error36 ExpectedRootHTML string37 ExpectedMainCSS string38 ExpectedManifestJSON string39 }{40 {41 "no changes required, empty subpath provided",42 baseRootHtml,43 baseCss,44 baseManifestJson,45 "",46 nil,47 baseRootHtml,48 baseCss,49 baseManifestJson,50 },51 {52 "no changes required",53 baseRootHtml,54 baseCss,55 baseManifestJson,56 "/",57 nil,58 baseRootHtml,59 baseCss,60 baseManifestJson,61 },62 {63 "content security policy not found (missing quotes)",64 contentSecurityPolicyNotFoundHtml,65 baseCss,66 baseManifestJson,67 "/subpath",68 fmt.Errorf("failed to find 'Content-Security-Policy' meta tag to rewrite"),69 contentSecurityPolicyNotFoundHtml,70 baseCss,71 baseManifestJson,72 },73 {74 "content security policy not found (missing unsafe-eval)",75 contentSecurityPolicyNotFound2Html,76 baseCss,77 baseManifestJson,78 "/subpath",79 fmt.Errorf("failed to find 'Content-Security-Policy' meta tag to rewrite"),80 contentSecurityPolicyNotFound2Html,81 baseCss,82 baseManifestJson,83 },84 {85 "subpath",86 baseRootHtml,87 baseCss,88 baseManifestJson,89 "/subpath",90 nil,91 subpathRootHtml,92 subpathCss,93 subpathManifestJson,94 },95 {96 "new subpath from old",97 subpathRootHtml,98 subpathCss,99 subpathManifestJson,100 "/nested/subpath",101 nil,102 newSubpathRootHtml,103 newSubpathCss,104 newSubpathManifestJson,105 },106 {107 "resetting to /",108 subpathRootHtml,109 subpathCss,110 baseManifestJson,111 "/",112 nil,113 baseRootHtml,114 baseCss,115 baseManifestJson,116 },117 }118 for _, testCase := range testCases {119 t.Run(testCase.Description, func(t *testing.T) {120 ioutil.WriteFile(filepath.Join(tempDir, model.CLIENT_DIR, "root.html"), []byte(testCase.RootHTML), 0700)121 ioutil.WriteFile(filepath.Join(tempDir, model.CLIENT_DIR, "main.css"), []byte(testCase.MainCSS), 0700)122 ioutil.WriteFile(filepath.Join(tempDir, model.CLIENT_DIR, "manifest.json"), []byte(testCase.ManifestJSON), 0700)123 err := utils.UpdateAssetsSubpath(testCase.Subpath)124 if testCase.ExpectedError != nil {125 require.Equal(t, testCase.ExpectedError, err)126 } else {127 require.NoError(t, err)128 }129 contents, err := ioutil.ReadFile(filepath.Join(tempDir, model.CLIENT_DIR, "root.html"))130 require.NoError(t, err)131 // Rewrite the expected and contents for simpler diffs when failed.132 expectedRootHTML := strings.Replace(testCase.ExpectedRootHTML, ">", ">\n", -1)133 contentsStr := strings.Replace(string(contents), ">", ">\n", -1)134 require.Equal(t, expectedRootHTML, contentsStr)135 contents, err = ioutil.ReadFile(filepath.Join(tempDir, model.CLIENT_DIR, "main.css"))136 require.NoError(t, err)137 require.Equal(t, testCase.ExpectedMainCSS, string(contents))138 contents, err = ioutil.ReadFile(filepath.Join(tempDir, model.CLIENT_DIR, "manifest.json"))139 require.NoError(t, err)140 require.Equal(t, testCase.ExpectedManifestJSON, string(contents))141 })142 }143 })144}145func TestGetSubpathFromConfig(t *testing.T) {146 sToP := func(s string) *string {147 return &s148 }149 testCases := []struct {150 Description string151 SiteURL *string152 ExpectedError bool153 ExpectedSubpath string154 }{155 {156 "empty SiteURL",157 sToP(""),158 false,159 "/",160 },161 {162 "invalid SiteURL",163 sToP("cache_object:foo/bar"),164 true,165 "",166 },167 {168 "nil SiteURL",169 nil,170 false,171 "/",172 },173 {174 "no trailing slash",175 sToP("http://localhost:8065"),176 false,177 "/",178 },179 {180 "trailing slash",181 sToP("http://localhost:8065/"),182 false,183 "/",184 },185 {186 "subpath, no trailing slash",187 sToP("http://localhost:8065/subpath"),188 false,189 "/subpath",190 },191 {192 "trailing slash",193 sToP("http://localhost:8065/subpath/"),194 false,195 "/subpath",196 },197 }198 for _, testCase := range testCases {199 t.Run(testCase.Description, func(t *testing.T) {200 config := &model.Config{201 ServiceSettings: model.ServiceSettings{202 SiteURL: testCase.SiteURL,203 },204 }205 subpath, err := utils.GetSubpathFromConfig(config)206 if testCase.ExpectedError {207 require.Error(t, err)208 } else {209 require.NoError(t, err)210 }211 require.Equal(t, testCase.ExpectedSubpath, subpath)212 })213 }214}215const contentSecurityPolicyNotFoundHtml = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv=Content-Security-Policy content="script-src 'self' cdn.segment.com/analytics.js/"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style> <link href="/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`216const contentSecurityPolicyNotFound2Html = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv=Content-Security-Policy content="script-src 'self' cdn.segment.com/analytics.js/ 'unsafe-eval'"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style> <link href="/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`217const baseRootHtml = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style> <link href="/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`218const baseCss = `@font-face{font-family:FontAwesome;src:url(/static/files/674f50d287a8c48dc19ba404d20fe713.eot);src:url(/static/files/674f50d287a8c48dc19ba404d20fe713.eot?#iefix&v=4.7.0) format("embedded-opentype"),url(/static/files/af7ae505a9eed503f8b8e6982036873e.woff2) format("woff2"),url(/static/files/fee66e712a8a08eef5805a46892932ad.woff) format("woff"),url(/static/files/b06871f281fee6b241d60582ae9369b9.ttf) format("truetype"),url(/static/files/677433a0892aaed7b7d2628c313c9775.svg#fontawesomeregular) format("svg");font-weight:400;font-style:normal}`219const subpathRootHtml = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/ 'sha256-tPOjw+tkVs9axL78ZwGtYl975dtyPHB6LYKAO2R3gR4='"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/subpath/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/subpath/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/subpath/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/subpath/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/subpath/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/subpath/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/subpath/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/subpath/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/subpath/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/subpath/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/subpath/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/subpath/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style><script>window.publicPath='/subpath/static/'</script> <link href="/subpath/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/subpath/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`220const subpathCss = `@font-face{font-family:FontAwesome;src:url(/subpath/static/files/674f50d287a8c48dc19ba404d20fe713.eot);src:url(/subpath/static/files/674f50d287a8c48dc19ba404d20fe713.eot?#iefix&v=4.7.0) format("embedded-opentype"),url(/subpath/static/files/af7ae505a9eed503f8b8e6982036873e.woff2) format("woff2"),url(/subpath/static/files/fee66e712a8a08eef5805a46892932ad.woff) format("woff"),url(/subpath/static/files/b06871f281fee6b241d60582ae9369b9.ttf) format("truetype"),url(/subpath/static/files/677433a0892aaed7b7d2628c313c9775.svg#fontawesomeregular) format("svg");font-weight:400;font-style:normal}`221const newSubpathRootHtml = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/ 'sha256-mbRaPRRpWz6MNkX9SyXWMJ8XnWV4w/DoqK2M0ryUAvc='"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/nested/subpath/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/nested/subpath/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/nested/subpath/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/nested/subpath/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/nested/subpath/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/nested/subpath/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/nested/subpath/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/nested/subpath/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/nested/subpath/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/nested/subpath/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/nested/subpath/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/nested/subpath/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style><script>window.publicPath='/nested/subpath/static/'</script> <link href="/nested/subpath/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/nested/subpath/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`222const newSubpathCss = `@font-face{font-family:FontAwesome;src:url(/nested/subpath/static/files/674f50d287a8c48dc19ba404d20fe713.eot);src:url(/nested/subpath/static/files/674f50d287a8c48dc19ba404d20fe713.eot?#iefix&v=4.7.0) format("embedded-opentype"),url(/nested/subpath/static/files/af7ae505a9eed503f8b8e6982036873e.woff2) format("woff2"),url(/nested/subpath/static/files/fee66e712a8a08eef5805a46892932ad.woff) format("woff"),url(/nested/subpath/static/files/b06871f281fee6b241d60582ae9369b9.ttf) format("truetype"),url(/nested/subpath/static/files/677433a0892aaed7b7d2628c313c9775.svg#fontawesomeregular) format("svg");font-weight:400;font-style:normal}`223const resetRootHtml = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.segment.com/analytics.js/ 'sha256-VFw7U/t/OI+I9YMja3c2GDwEQbnlOq/L5+GealgesK8='"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style><script>window.publicPath='/static/'</script> <link href="/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`224const baseManifestJson = `{225 "icons": [226 {227 "src": "/static/icon_96x96.png",228 "sizes": "96x96",229 "type": "image/png"230 },231 {232 "src": "/static/icon_32x32.png",233 "sizes": "32x32",234 "type": "image/png"235 },236 {237 "src": "/static/icon_16x16.png",238 "sizes": "16x16",239 "type": "image/png"240 },241 {242 "src": "/static/icon_76x76.png",243 "sizes": "76x76",244 "type": "image/png"245 },246 {247 "src": "/static/icon_72x72.png",248 "sizes": "72x72",249 "type": "image/png"250 },251 {252 "src": "/static/icon_60x60.png",253 "sizes": "60x60",254 "type": "image/png"255 },256 {257 "src": "/static/icon_57x57.png",258 "sizes": "57x57",259 "type": "image/png"260 },261 {262 "src": "/static/icon_152x152.png",263 "sizes": "152x152",264 "type": "image/png"265 },266 {267 "src": "/static/icon_144x144.png",268 "sizes": "144x144",269 "type": "image/png"270 },271 {272 "src": "/static/icon_120x120.png",273 "sizes": "120x120",274 "type": "image/png"275 },276 {277 "src": "/static/icon_192x192.png",278 "sizes": "192x192",279 "type": "image/png"280 }281 ],282 "name": "Mattermost",283 "short_name": "Mattermost",284 "orientation": "any",285 "display": "standalone",286 "start_url": ".",287 "description": "Mattermost is an open source, self-hosted Slack-alternative",288 "background_color": "#ffffff"289}290`291const subpathManifestJson = `{292 "icons": [293 {294 "src": "/subpath/static/icon_96x96.png",295 "sizes": "96x96",296 "type": "image/png"297 },298 {299 "src": "/subpath/static/icon_32x32.png",300 "sizes": "32x32",301 "type": "image/png"302 },303 {304 "src": "/subpath/static/icon_16x16.png",305 "sizes": "16x16",306 "type": "image/png"307 },308 {309 "src": "/subpath/static/icon_76x76.png",310 "sizes": "76x76",311 "type": "image/png"312 },313 {314 "src": "/subpath/static/icon_72x72.png",315 "sizes": "72x72",316 "type": "image/png"317 },318 {319 "src": "/subpath/static/icon_60x60.png",320 "sizes": "60x60",321 "type": "image/png"322 },323 {324 "src": "/subpath/static/icon_57x57.png",325 "sizes": "57x57",326 "type": "image/png"327 },328 {329 "src": "/subpath/static/icon_152x152.png",330 "sizes": "152x152",331 "type": "image/png"332 },333 {334 "src": "/subpath/static/icon_144x144.png",335 "sizes": "144x144",336 "type": "image/png"337 },338 {339 "src": "/subpath/static/icon_120x120.png",340 "sizes": "120x120",341 "type": "image/png"342 },343 {344 "src": "/subpath/static/icon_192x192.png",345 "sizes": "192x192",346 "type": "image/png"347 }348 ],349 "name": "Mattermost",350 "short_name": "Mattermost",351 "orientation": "any",352 "display": "standalone",353 "start_url": ".",354 "description": "Mattermost is an open source, self-hosted Slack-alternative",355 "background_color": "#ffffff"356}357`358const newSubpathManifestJson = `{359 "icons": [360 {361 "src": "/nested/subpath/static/icon_96x96.png",362 "sizes": "96x96",363 "type": "image/png"364 },365 {366 "src": "/nested/subpath/static/icon_32x32.png",367 "sizes": "32x32",368 "type": "image/png"369 },370 {371 "src": "/nested/subpath/static/icon_16x16.png",372 "sizes": "16x16",373 "type": "image/png"374 },375 {376 "src": "/nested/subpath/static/icon_76x76.png",377 "sizes": "76x76",378 "type": "image/png"379 },380 {381 "src": "/nested/subpath/static/icon_72x72.png",382 "sizes": "72x72",383 "type": "image/png"384 },385 {386 "src": "/nested/subpath/static/icon_60x60.png",387 "sizes": "60x60",388 "type": "image/png"389 },390 {391 "src": "/nested/subpath/static/icon_57x57.png",392 "sizes": "57x57",393 "type": "image/png"394 },395 {396 "src": "/nested/subpath/static/icon_152x152.png",397 "sizes": "152x152",398 "type": "image/png"399 },400 {401 "src": "/nested/subpath/static/icon_144x144.png",402 "sizes": "144x144",403 "type": "image/png"404 },405 {406 "src": "/nested/subpath/static/icon_120x120.png",407 "sizes": "120x120",408 "type": "image/png"409 },410 {411 "src": "/nested/subpath/static/icon_192x192.png",412 "sizes": "192x192",413 "type": "image/png"414 }415 ],416 "name": "Mattermost",417 "short_name": "Mattermost",418 "orientation": "any",419 "display": "standalone",420 "start_url": ".",421 "description": "Mattermost is an open source, self-hosted Slack-alternative",422 "background_color": "#ffffff"423}424`...

Full Screen

Full Screen

templates.go

Source:templates.go Github

copy

Full Screen

1// OBSOLETED by templates/*.tmpl2// Templates for webui3package main4import (5 "fmt"6 "html/template"7)8const menu = `9 <div class="navbar">10 <div class="navbar-inner">11 <a class="brand" href="/">Stream Surfer</a>12 <ul class="nav">13 <li><a href="/status">Status</a></li>14 <li><a href="/ctrl">Control</a></li>15 <li class="active"><a href="/rprt">Reports</a></li>16 <li><a href="http://streamsurfer.org">Documentation</a></li>17 </ul>18 </div>19 </div>20`21type TestMe struct {22 Test int23}24var (25 tmpltReportStreamInfo = `<!DOCTYPE html>26<html lang="en">27<head>28<meta charset="utf-8">29<title>Stream Surfer Reports</title>30<meta name="description" content="Creating a table with Twitter Bootstrap. Learn how to use Twitter Bootstrap toolkit to create Tables with examples.">31<link href="/css/bootstrap.min.css" rel="stylesheet">32<link href="/css/custom.css" rel="stylesheet">33</head>34<body>35<h1>Reports are:</h1>36 <ul>37 {{range $i, $val := .}}38 <li><a href="rprt/{{$i}}">{{$val}}</a></li>39 {{end}}40 </ul>41</body>42<a href="http://streamsurfer.org"><img src="/logo-64.png" /></a><br />43</html>44`45 tmpltReportStreamHistory = `<!DOCTYPE html>46<html lang="en">47<head>48<meta charset="utf-8">49<title>Stream Surfer Reports</title>50<meta name="description" content="Creating a table with Twitter Bootstrap. Learn how to use Twitter Bootstrap toolkit to create Tables with examples.">51<link href="/css/bootstrap.min.css" rel="stylesheet">52<link href="/css/custom.css" rel="stylesheet">53</head>54<body>55<h1>Errors per 3 hours for all groups</h1>56<table class="table table-bordered table-condensed">57 <thead>58 <tr>59</table>60</body>61<a href="http://streamsurfer.org"><img src="/logo-64.png" /></a><br />62</html>63`64)65/// ниже устаревшие шаблоны ///////////////////////////////////////////////////////////////////////////////66/// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv67var (68 ReportMainPageTemplate = fmt.Sprintf(`<!DOCTYPE html>69<html lang="en">70<head>71<meta charset="utf-8">72<title>Stream Surfer Reports</title>73<meta name="description" content="Creating a table with Twitter Bootstrap. Learn how to use Twitter Bootstrap toolkit to create Tables with examples.">74<link href="/css/bootstrap.min.css" rel="stylesheet">75<link href="/css/custom.css" rel="stylesheet">76</head>77<body>78%s79<h1>Reports are:</h1>80 <ul>81 <li><a href="rprt/3hours">Errors for all streams for last 3 hours</a></li>82 <li><a href="rprt/last">Last streams errors (complete)</a></li>83 <li><a href="rprt/last-critical">Last streams errors (critical only)</a></li>84 </ul>85</body>86<a href="http://streamsurfer.org"><img src="/logo-64.png" /></a><br />87</html>88`, menu)89 Report3HoursTemplate = fmt.Sprintf(`<!DOCTYPE html>90<html lang="en">91<head>92<meta charset="utf-8">93<title>Errors per 3 hours for all groups :: Stream Surfer</title>94<meta name="description" content="Creating a table with Twitter Bootstrap. Learn how to use Twitter Bootstrap toolkit to create Tables with examples.">95<link href="/css/bootstrap.min.css" rel="stylesheet">96<link href="/css/custom.css" rel="stylesheet">97<script src="/js/bootstrap.min.js"></script>98</head>99<body>100%s101<h1>Errors per 3 hours for all groups</h1>102<table class="table table-bordered table-condensed">103 <thead>104 <tr>105 <th rowspan="2">Group</th>106 <th rowspan="2">Name</th>107 <th colspan="6">Last hour</th>108 <th colspan="6">Two hours ago</th>109 <th colspan="6">Three hours ago</th>110 </tr>111 <tr>112 <th rel="tooltip" title="Slow response">SR</th>113 <th rel="tooltip" title="Bad status">BS</th>114 <th rel="tooltip" title="Bad URI">BU</th>115 <th rel="tooltip" title="Timeout on read">RT</th>116 <th rel="tooltip" title="Timeout on connect">CT</th>117 <th rel="tooltip" title="Slow response">SR</th>118 <th rel="tooltip" title="Bad status">BS</th>119 <th rel="tooltip" title="Bad URI">BU</th>120 <th rel="tooltip" title="Timeout on read">RT</th>121 <th rel="tooltip" title="Timeout on connect">CT</th>122 <th rel="tooltip" title="Slow response">SR</th>123 <th rel="tooltip" title="Bad status">BS</th>124 <th rel="tooltip" title="Bad URI">BU</th>125 <th rel="tooltip" title="Timeout on read">RT</th>126 <th rel="tooltip" title="Timeout on connect">CT</th>127 <th rel="tooltip" title="Connection refused">CR</th>128 </tr>129 </thead>130 <tbody>131 {{#TableData}}132 <tr>133 <td><a href="/rprt/g/{{group}}/3hours">{{group}}</a></td>134 <td><a href="{{uri}}">{{name}}</a></td>135 <td{{#sw-severity}} class="{{sw-severity}}"{{/sw-severity}} rel="tooltip" title="Slow response">{{sw}}</td>136 <td{{#bs-severity}} class="{{bs-severity}}"{{/bs-severity}} rel="tooltip" title="Bad status">{{bs}}</td>137 <td{{#bu-severity}} class="{{bu-severity}}"{{/bu-severity}} rel="tooltip" title="Bad URI">{{bu}}</td>138 <td{{#rt-severity}} class="{{rt-severity}}"{{/rt-severity}} rel="tooltip" title="Timeout on read">{{rt}}</td>139 <td{{#ct-severity}} class="{{ct-severity}}"{{/ct-severity}} rel="tooltip" title="Timeout on connect">{{ct}}</td>140 <td{{#cr-severity}} class="{{cr-severity}}"{{/cr-severity}} rel="tooltip" title="Slow response">{{cr}}</td>141 <td>{{sw2}}</td>142 <td>{{bs2}}</td>143 <td>{{bs2}}</td>144 <td>{{rt2}}</td>145 <td>{{ct2}}</td>146 <td>{{cr2}}</td>147 <td>{{sw3}}</td>148 <td>{{bs3}}</td>149 <td>{{bu3}}</td>150 <td>{{rt3}}</td>151 <td>{{ct3}}</td>152 <td>{{cr3}}</td>153 </tr>154 {{/TableData}}155 </tbody>156</table>157<a href="http://streamsurfer.org"><img src="/logo-64.png" /></a><br />158Generated by <a href="http://streamsurfer.org">Stream Surfer</a>159</body>160</html>161`, menu)162 ReportLastTemplate = fmt.Sprintf(`<!DOCTYPE html>163<html lang="en">164<head>165<meta charset="utf-8">166<title>All groups last errors :: Stream Surfer</title>167<meta name="description" content="Creating a table with Twitter Bootstrap. Learn how to use Twitter Bootstrap toolkit to create Tables with examples.">168<link href="/css/bootstrap.min.css" rel="stylesheet">169<link href="/css/custom.css" rel="stylesheet">170<script src="/js/bootstrap.min.js"></script>171</head>172<body>173%s174<h1>Last errors</h1>175<table class="table table-bordered table-condensed">176 <thead>177 <tr>178 <th>Group</th>179 <th>Name</th>180 <th>Status</th>181 <th>Length</th>182 <th>Request Duration</th>183 <th>Last Checked</th>184 <th>Error</th>185 <th>Last Hour</th>186 </tr>187 </thead>188 <tbody>189 {{#TableData}}190 <tr class="{{severity}}">191 <td><a href="/rprt/g/{{group}}/{{report}}">{{group}}</a></td>192 <td><a href="{{uri}}">{{name}}</a></td>193 <td>{{status}}</td>194 <td>{{contentlength}}</td>195 <td>{{elapsed}}</td>196 <td>{{started}}</td>197 <td>{{error}}</td>198 <td>{{totalerrs}}</td>199 </tr>200 {{/TableData}}201 </tbody>202</table>203<a href="http://streamsurfer.org"><img src="/logo-64.png" /></a><br />204Generated by <a href="http://streamsurfer.org">Stream Surfer</a>205</body>206</html>207`, menu)208 ReportGroupLastTemplate = fmt.Sprintf(`<!DOCTYPE html>209<html lang="en">210<head>211<meta charset="utf-8">212<title>{{#Vars}}{{group}} :: {{/Vars}}Stream Surfer</title>213<meta name="description" content="Creating a table with Twitter Bootstrap. Learn how to use Twitter Bootstrap toolkit to create Tables with examples.">214<link href="/css/bootstrap.min.css" rel="stylesheet">215<link href="/css/custom.css" rel="stylesheet">216<script src="/js/bootstrap.min.js"></script>217</head>218<body>219%s220{{#Vars}}<h1>{{group}} last errors</h1>{{/Vars}}221<table class="table table-bordered table-condensed sortered">222 <thead>223 <tr>224 <th>Name</th>225 <th>Status</th>226 <th>Length</th>227 <th>Request Duration</th>228 <th>Last Checked</th>229 <th>Error</th>230 <th>Last Hour</th>231 </tr>232 </thead>233 <tbody>234 {{#TableData}}235 <tr class="{{severity}}">236 <td><a href="{{uri}}">{{name}}</a></td>237 <td>{{status}}</td>238 <td>{{contentlength}}</td>239 <td>{{elapsed}}</td>240 <td>{{started}}</td>241 <td>{{error}}</td>242 <td>{{totalerrs}}</td>243 </tr>244 {{/TableData}}245 </tbody>246</table>247<a href="http://streamsurfer.org"><img src="/logo-64.png" /></a><br />248Generated by <a href="http://streamsurfer.org">Stream Surfer</a>249</body>250</html>`, menu)251)252var IndexPageTemplate = template.Must(template.ParseFiles("html/index.html"))...

Full Screen

Full Screen

listing.go

Source:listing.go Github

copy

Full Screen

...54 if !tree.IsDir {55 return56 }57 // don't want to recursively go into the root dir58 if tree.RelPath == "." && !root {59 return60 }61 if len(tree.Children) == 0 {62 return63 }64 // check if an index file already exists65 hasIndex := false66 for _, child := range tree.Children {67 if child.Name == "index.html" {68 hasIndex = true69 break70 }71 }72 if !hasIndex {73 var relPath string74 if tree.RelPath == "." {75 relPath = "index.html"76 } else {77 relPath = fmt.Sprintf("%s/index.html", tree.RelPath)78 }79 reader := a.makeListingReader(tree)80 index := &File{81 RelPath: relPath,82 Name: "index.html",83 IsDir: false,84 Reader: reader,85 Size: reader.Size(),86 contentType: "text/html",87 }88 a.tree[index.RelPath] = index89 tree.Children = append(tree.Children, index)90 a.files = append(a.files, *index)91 }92 for _, child := range tree.Children {93 a.addFileListing(child, false)94 }95}96func (a *Airlock) makeListingReader(tree *File) *bytes.Reader {97 var out bytes.Buffer98 err := a.listingTmpl.Execute(&out, tree)99 if err != nil {100 log.Printf("error generating file listing for %s: %v\n", tree.RelPath, err)101 out = *bytes.NewBufferString("")102 }103 return bytes.NewReader(out.Bytes())104}...

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import (2func main() {3}4func Rel(base, target string) string5rel := base.Rel(base, target)6import (7func main() {8 rel := base.Rel(base, target)9 fmt.Println(rel)10}11The URL type represents a parsed URL (technically, a URI reference). The general form represented is:12&url.URL{Scheme:"", Opaque:"", User:nil, Host:"", Path:"", RawPath:"", ForceQuery:false, RawQuery:"", Fragment:""}

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("This is <b>HTML</b>"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("This is &lt;b&gt;HTML&lt;/b&gt;"))8}9import (10func main() {11 fmt.Println(html.EscapeString("This is <b>HTML</b>"))12}13import (14func main() {15 fmt.Println(html.UnescapeString("This is &lt;b&gt;HTML&lt;/b&gt;"))16}17import (18func main() {19 fmt.Println(html.EscapeString("This is <b>HTML</b>"))20}21import (22func main() {23 fmt.Println(html.UnescapeString("This is &lt;b&gt;HTML&lt;/b&gt;"))24}25import (26func main() {27 fmt.Println(html.EscapeString("This is <b>HTML</b>"))28}29import (

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 req := http.Request{7 }8 resp := http.Response{9 }10 rel, err := resp.Request.URL.Parse(link)11 if err != nil {12 fmt.Println(err)13 }14 fmt.Println(rel)15}16import (17func main() {18 if err != nil {19 fmt.Println(err)20 }21 rel, err := u.Parse(link)22 if err != nil {23 fmt.Println(err)24 }25 fmt.Println(rel)26}27import (28func main() {29 if err != nil {30 fmt.Println(err)31 }32 rel, err := u.ResolveReference(&url.URL{Path: link})33 if err != nil {34 fmt.Println(err)35 }36 fmt.Println(rel)37}38import (39func main() {

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import (2func main() {3}4import (5func main() {6}7import (8func main() {9}10import (11func main() {12}13import (14func main() {15 fmt.Println(html.Rel

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 s = html.EscapeString(s)4 fmt.Println(s)5}6Go EscapeString() Method7func EscapeString(s string) string8import (9func main() {10 s = html.EscapeString(s)11 fmt.Println(s)12}13Go UnescapeString() Method14func UnescapeString(s string) string15import (16func main() {17 s = html.UnescapeString(s)18 fmt.Println(s)19}20Go QueryEscape() Method21func QueryEscape(s string) string22import (23func main() {24 s = html.QueryEscape(s)25 fmt.Println(s)26}27Go QueryUnescape() Method28func QueryUnescape(s

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "strings"3func main() {4 fmt.Println(strings.Repeat("-", 10))5 fmt.Println("Join:", strings.Join([]string{"a", "b"}, "-"))6 fmt.Println("Repeat:", strings.Repeat("a", 5))7 fmt.Println("Replace:", strings.Replace("foo", "o", "0", -1))8 fmt.Println("Replace:", strings.Replace("foo", "o", "0", 1))9 fmt.Println("Split:", strings.Split("a-b-c-d-e", "-"))10 fmt.Println("ToLower:", strings.ToLower("TEST"))11 fmt.Println("ToUpper:", strings.ToUpper("test"))12 fmt.Println("Len:", len("hello"))13 fmt.Println("Char:", "hello"[1])14}15import "fmt"16import "strings"17func main() {18 fmt.Println(strings.Contains("test", "es"))19 fmt.Println(strings.Count("test", "t"))20 fmt.Println(strings.HasPrefix("test", "te"))21 fmt.Println(strings.HasSuffix("test", "st"))22 fmt.Println(strings.Index("test", "e"))23 fmt.Println(strings.Index("test", "x"))24 fmt.Println(strings.Join([]string{"a", "b"}, "-"))25 fmt.Println("ba" + strings.Repeat("na", 2))26 fmt.Println(strings.Replace("foooo", "o", "0", -1))27 fmt.Println(strings.Replace("foooo", "o", "0", 2))28 fmt.Println(strings.Split("a-b-c-d-e", "-"))29 fmt.Println(strings.ToLower("TEST"))30 fmt.Println(strings.ToUpper("test"))31 fmt.Println(len("hello"))32 fmt.Println("hello"[1])33}34import "fmt"35import "strings"36func main() {37 fmt.Println(strings.Contains("test", "

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 u, err := url.Parse(urlToParse)4 if err != nil {5 panic(err)6 }7 fmt.Println(u)8 fmt.Println(u.Path)9 fmt.Println(html.Rel(u.Path, "/a/b/c/g;hi?y#s"))10}11/a/b/c/d;p12../g;hi?y#s

Full Screen

Full Screen

Rel

Using AI Code Generation

copy

Full Screen

1func main() {2 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src"))3 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/"))4 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/1.go"))5 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/2.go"))6 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/1.go/"))7 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/2.go/"))8 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/1.go/2.go"))9 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/2.go/1.go"))10 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/1.go/2.go/"))11 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/2.go/1.go/"))12 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/1.go/2.go/1.go"))13 fmt.Println(filepath.Rel("/home/user1", "/home/user1/go/src/2.go/1.go/2.go"))14 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src"))15 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/"))16 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/1.go"))17 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/2.go"))18 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/1.go/"))19 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/2.go/"))20 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/1.go/2.go"))21 fmt.Println(filepath.Rel("/home/user1", "/home/user2/go/src/2.go/1.go"))

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful