Skip to content

Commit 5830480

Browse files
committed
[refactor] replace two duplicate decodeURIComponentSave functions with one shared version
1 parent d9571fd commit 5830480

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

api/router.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ var parsePathname = require("../pathname/parse")
88
var compileTemplate = require("../pathname/compileTemplate")
99
var censor = require("../util/censor")
1010

11-
function decodeURIComponentSave(component) {
12-
try {
13-
return decodeURIComponent(component)
14-
} catch(e) {
15-
return component
16-
}
17-
}
11+
var decodeURIComponentSave = require("../util/decodeURIComponentSave")
1812

1913
module.exports = function($window, mountRedraw) {
2014
var p = Promise.resolve()

querystring/parse.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
"use strict"
22

3-
function decodeURIComponentSave(str) {
4-
try {
5-
return decodeURIComponent(str)
6-
} catch(err) {
7-
return str
8-
}
9-
}
3+
var decodeURIComponentSave = require("../util/decodeURIComponentSave")
104

115
module.exports = function(string) {
126
if (string === "" || string == null) return {}

util/decodeURIComponentSave.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict"
2+
3+
module.exports = function(str) {
4+
try {
5+
return decodeURIComponent(str)
6+
} catch(err) {
7+
return str
8+
}
9+
}

0 commit comments

Comments
 (0)