aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/utils
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-03-14 17:51:20 +0800
committerGitHub <noreply@github.com>2023-03-14 17:51:20 +0800
commitac8d71ff07a3354a27d6a5daab45d1e79e242269 (patch)
treebcf34685ce59b0ad89903ac769c4080dc1073349 /web_src/js/utils
parentd56bb7420184c0c2f451f4bcaa96c9b3b00c393d (diff)
downloadgitea-ac8d71ff07a3354a27d6a5daab45d1e79e242269.tar.gz
gitea-ac8d71ff07a3354a27d6a5daab45d1e79e242269.zip
Refactor branch/tag selector to Vue SFC (#23421)
Follow #23394 There were many bad smells in old code. This PR only moves the code into Vue SFC, doesn't touch the unrelated logic. update: after https://github.com/go-gitea/gitea/pull/23421/commits/5f23218c851e12132f538a404c946bbf6ff38e62 , there should be no usage of the vue-rumtime-compiler anymore (hopefully), so I think this PR could close #19851 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'web_src/js/utils')
-rw-r--r--web_src/js/utils/url.js3
-rw-r--r--web_src/js/utils/url.test.js7
2 files changed, 10 insertions, 0 deletions
diff --git a/web_src/js/utils/url.js b/web_src/js/utils/url.js
new file mode 100644
index 0000000000..a40737ca6f
--- /dev/null
+++ b/web_src/js/utils/url.js
@@ -0,0 +1,3 @@
+export function pathEscapeSegments(s) {
+ return s.split('/').map(encodeURIComponent).join('/');
+}
diff --git a/web_src/js/utils/url.test.js b/web_src/js/utils/url.test.js
new file mode 100644
index 0000000000..ef2ffaa5f9
--- /dev/null
+++ b/web_src/js/utils/url.test.js
@@ -0,0 +1,7 @@
+import {expect, test} from 'vitest';
+import {pathEscapeSegments} from './url.js';
+
+test('pathEscapeSegments', () => {
+ expect(pathEscapeSegments('a/b/c')).toEqual('a/b/c');
+ expect(pathEscapeSegments('a/b/ c')).toEqual('a/b/%20c');
+});