Skip to end of metadata
Go to start of metadata

Zend Framework: Zend_Filter_PrependHttp Component Proposal

Proposed Component Name Zend_Filter_PrependHttp
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Filter_PrependHttp
Proposers Chris Morrell
Zend Liaison TBD
Revision 1.0 - 1 January 2008: Initial Draft. (wiki revision: 3)

Table of Contents

1. Overview

Zend_Filter_PrependHttp is a Zend_Filter component that prepends "http://" to the beginning of a URI that doesn't have a valid scheme already attached to it.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will implement Zend_Filter_Interface
  • this component will prepend "http://" to strings that do not already start with an allowed scheme

4. Dependencies on Other Framework Components

  • Zend_Filter_Exception
  • Zend_Filter_Interface
  • Zend_Uri

5. Theory of Operation

This filter will be most useful for user-submitted URLs that may or may not have a valid scheme component. In the event that an otherwise valid URI does not have a scheme component, the filter will add "http://" (which is the most likely scheme if left off).

6. Milestones / Tasks

  • Milestone 1: Proposal finished
  • Milestone 2: [DONE] Working prototype finished
  • Milestone 3: Working prototype checked into the incubator
  • Milestone 4: Unit tests exist, work, and are checked into SVN.
  • Milestone 5: Initial documentation exists.

7. Class Index

  • Zend_Filter_PrependHttp

8. Use Cases

UC-01
UC-02
UC-03

9. Class Skeletons

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Mar 12, 2010

    Some thoughts:

    Would it make more sense to change this to Zend_Filter_PrependScheme and set the default scheme to "http://"?  That would let you define any scheme you want as the default.

    In that case, would a better name be Zend_Filter_UriScheme?

    Would it make sense to replace the supplied scheme if it's not in the allowed schemes?  For example, if someone supplied "itms://itunes.apple.com/" and "itms://" wasn't a valid scheme, should it replace it with "http://itunes.apple.com" rather than just prepending (resulting in an invalid URI "http://itms://itunes.apple.com/")?

  2. Mar 13, 2010

    PrependScheme or UriScheme sounds better to me.

    Replacing if another but not wanted scheme is provided would be nice, that's something I don't have in my Filter ( http://github.com/robo47/Robo47-Components/blob/master/library/Robo47/Filter/UrlScheme.php ) yet

    For generic use it should propably be configureable to allow some kind of wildcard als scheme, so every scheme is allowed, there just needs to be one.

  3. May 13, 2010

    I think a more generic functionality would be better. Think of two filters like Zend_Filter_Append and Zend_Filter_Prepend both with an option to force the string to be pre-/appended or to only pre-/append it if the string to be filtered doesn't start/end with it.

    1. Jul 11, 2010

      I really like this idea rather than a filter specifically for http. Perhaps a 'scheme' filter could still exist (that only allows valid schemes...user defined, but with sensible defaults) that internally uses Zend_Filter_Prepend to do the prepend. It just filters out invalid themes before hand

  4. Jul 12, 2010

    Supporting relative schemes would be nice as well. In other words, allow "//" which means use the current scheme.

    See: http://stackoverflow.com/questions/2458735/using-in-a-scripts-source/2458861#2458861

  5. Feb 05, 2011

    Archiving this proposal, feel free to recover it when you want to work on it again. For more details see this email.