Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
GMRouter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMRouter
Commits
924c112e
Commit
924c112e
authored
Dec 23, 2019
by
jz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update GMRouter
parent
09124efa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
GMRouter+gm.m
GMRouter/Classes/GMRouter+gm.m
+29
-18
No files found.
GMRouter/Classes/GMRouter+gm.m
View file @
924c112e
...
...
@@ -133,47 +133,58 @@ static NSMutableDictionary *routeMap = nil;
}
NSString
*
host
=
url
.
host
;
NSString
*
targetName
=
[
routeMap
objectForKey
:
host
];
NSDictionary
*
params
=
[
self
getParams
:
encodeUrlScheme
withHost
:
host
];
host
=
[
self
getHostWithEncodeUrlScheme
:
encodeUrlScheme
host
:
host
];
return
[
self
performTarget
:
targetName
action
:
host
params
:
params
shouldCacheTarget
:
NO
];
}
-
(
NSDictionary
*
)
getParams
:
(
NSString
*
)
encodeUrlScheme
withHost
:
(
NSString
*
)
host
{
NSDictionary
*
params
;
NSArray
*
array
=
[
encodeUrlScheme
componentsSeparatedByString
:
@"url="
];
if
(([
host
isEqualToString
:
@"third_webview"
]
||
[
host
isEqualToString
:
@"common_webview"
])
&&
array
.
count
>
1
)
{
NSString
*
value
=
array
[
1
];
while
([
value
rangeOfString
:
@"%"
].
length
!=
0
)
{
//拦截所有的即将调转的url(value),如果不在白名单之中,让其使用GMThirdWebViewController加载.
NSString
*
valueHost
=
[[
NSURL
URLWithString
:
value
]
host
];
if
([
value
rangeOfString
:
@"%"
].
length
!=
0
)
{
value
=
[
self
URLDecodedString
:
value
];
}
params
=
@{
@"url"
:
value
};
//拦截所有的即将调转的url(value),如果不在白名单之中,让其使用GMThirdWebViewController加载.
NSString
*
valueHost
=
[[
NSURL
URLWithString
:
value
]
host
];
// if ([GMServerDomains allowURLHost:valueHost] == NO) {
//#if defined DEBUG
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"webView需添加白名单" message:value delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
// [alertView show];
//#endif
//
// host = @"third_webview";
// }
}
else
{
params
=
[
self
urlQueryToDictionary
:
encodeUrlScheme
];
}
return
params
;
}
// NSDictionary *params = [self urlQueryToDictionary:encodeUrlScheme];
return
[
self
performTarget
:
targetName
action
:
host
params
:
params
shouldCacheTarget
:
NO
];
-
(
NSString
*
)
getHostWithEncodeUrlScheme
:
(
NSString
*
)
encodeUrlScheme
host
:
(
NSString
*
)
host
{
NSArray
*
array
=
[
encodeUrlScheme
componentsSeparatedByString
:
@"url="
];
if
(([
host
isEqualToString
:
@"third_webview"
]
||
[
host
isEqualToString
:
@"common_webview"
])
&&
array
.
count
>
1
)
{
NSString
*
value
=
array
[
1
];
//拦截所有的即将调转的url(value),如果不在白名单之中,让其使用GMThirdWebViewController加载.
NSString
*
valueHost
=
[[
NSURL
URLWithString
:
value
]
host
];
Class
cls
=
NSClassFromString
(
@"GMServerDomains"
);
if
([
cls
respondsToSelector
:
@selector
(
allowURLHost
:)])
{
BOOL
isAllow
=
[
cls
performSelector
:
@selector
(
allowURLHost
:)
withObject
:
valueHost
];
if
(
!
isAllow
)
{
host
=
@"third_webview"
;
}
}
}
return
host
;
}
-
(
id
)
pushScheme
:
(
NSString
*
)
urlScheme
params
:
(
NSDictionary
*
)
params
{
NSString
*
encodeUrlScheme
=
[
self
URL
Decoded
String
:
urlScheme
];
NSString
*
encodeUrlScheme
=
[
self
URL
Encode
String
:
urlScheme
];
NSURL
*
url
=
[
NSURL
URLWithString
:
encodeUrlScheme
];
if
(
!
url
)
{
// debugLog(@"协议出错了!");
}
NSString
*
host
=
url
.
host
;
NSString
*
targetName
=
[
routeMap
objectForKey
:
host
];
NSDictionary
*
paramsDict
=
[
self
urlQueryToDictionary
:
encodeUrlScheme
];
NSDictionary
*
paramsDict
=
[
self
getParams
:
encodeUrlScheme
withHost
:
host
];
host
=
[
self
getHostWithEncodeUrlScheme
:
encodeUrlScheme
host
:
host
];
return
[
self
performTarget
:
targetName
action
:
host
params
:
paramsDict
shouldCacheTarget
:
NO
];
}
#pragma mark - string to dict
-
(
NSDictionary
*
)
urlQueryToDictionary
:
(
NSString
*
)
urlScheme
{
NSURL
*
url1
=
[
NSURL
URLWithString
:
urlScheme
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment