简体   繁体   English

通过Javascript修复/清理用户提供的URL

[英]Fixing/cleaning user-provided URLs via Javascript

Does anyone happen to have javascript code focused on cleaning up user-provided URLs? 是否有人碰巧将JavaScript代码集中在清理用户提供的URL上? I have a mobile app that asks users to enter their website URL, and many times the URLs are not properly formatted, lack the http:// prefix, etc. (Typing on mobile tends to be error prone) I often see stuff like: 我有一个移动应用程序,要求用户输入他们的网站URL,并且很多时候URL的格式不正确,缺少http://前缀等。(在移动设备上键入内容容易出错),我经常看到类似以下内容:

google.com
ww.google.com
http//www.goggle.com
http://www..google.com

I know there'd be a certain amount of assuming one would have to do to clean a URL, but it just seems like there would be a library out there somewhere for URL cleaning? 我知道会有一定的假设要清理URL,但是似乎那里有一个库可以清理URL?

I guess this is as best of a start as you can get. 我想这是最好的开始。 It now deals with: .co.uk or whatever multi-part domain types, protocol, www-less, protocol-less etc. I plan to make it a library plugin. 现在它处理:.co.uk或任何多部分域类型,协议,无www,无协议等。我计划将其制作为库插件。

https://github.com/WebSudosUK/framework/blob/master/com.websudos.urlMatcher.js https://github.com/WebSudosUK/framework/blob/master/com.websudos.urlMatcher.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将用户提供的Javascript库列入白名单吗? - Can I whitelist libraries available to user-provided Javascript? 如何检测和停止用户提供的 JavaScript 代码中的无限循环? - How to detect and stop an infinite loop in user-provided JavaScript code? 如何运行用户提供的Javascript没有安全问题(如jsFiddle,jsBin等)? - How to run user-provided Javascript without security issues (like jsFiddle, jsBin, etc.)? Even with the inline JavaScript function - Google ReCAPTCHA couldn't find user-provided function: function (response) - - Even with the inline JavaScript function - Google ReCAPTCHA couldn't find user-provided function: function (response) - 如何在Android应用中运行用户提供的任意代码? - How to run user-provided, arbitrary code in an android app? 解析登录后未返回用户提供的字段 - User-provided fields not returned upon parse-login 如何获得用户提供的图像的链接? - How do I get the link of the user-provided image? 上传,处理,存储和交付用户提供的文件和图像 - uploading, processing, storing and delivering user-provided files and images JS / XSS:将用户提供的字符串分配给变量时; 是否足以替换&lt;,&gt;和字符串分隔符? - JS/XSS: When assigning user-provided strings to variables; is it enough to replace <,>, and string delimiter? 将用户提供的URL数据安全准确地插入HTML5文档的正确方法是什么? - What is the right way to safely and accurately insert user-provided URL data into an HTML5 document?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM