HuolalaTech / HLLOfflineWebVC-iOS

iOS offline package solution for H5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

拦截中用loadFileURL 去加载本地文件 不会导致文档的host 错乱吗,想了解

Chaste1ove99 opened this issue · comments

- (void)_hllofflineWebVc_load:(NSURL *)url { if (url.isFileURL) { NSString *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject; NSString *accessPath = [documentPath stringByAppendingString:@"/offlineWeb"]; NSURL *resource = [NSURL fileURLWithPath:accessPath]; [self.webView loadFileURL:url allowingReadAccessToURL:resource]; } else { [self.webView loadRequest:[NSURLRequest requestWithURL:url]]; } }

这个方法使用loadFileURL 来加载主文档 但是url的host 是指向本地bundle的 这样处理不会导致主文档的host 变更吗
业务对这样处理是无感的吗

调用loadFileURL 来加载主文档后,相当于url地址变成了本机地址,host会变化,所以服务端需要做跨域处理。