working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,149 snippets matching: slash

    public by chilly_bang  1855  4  6  0

    Force trailing slash, redirect .html to trailing slash, delete more then one slash

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #Redirects .html to trailing slash
    RewriteRule (.+)\.html$ /$1/ [L,R=301]
    #force trailing slash
    RewriteCond %{REQUEST_URI} !(/$|\.) 
    RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
    # entfernt mehrfache Slashes
    RewriteCond %{REQUEST_URI} ^(.*)\/\/+(.*)$ 
    RewriteRule ^(.*)$ %1/%2 [R=301,L]
    </IfModule>

    public by micurs  2842  1  7  0

    Find all Internal Links

    Regular expression that find all links that start with the sites domain, a slash, relative file path, or a hashtag. This regex can be used to find all the internal links in a page or section of a page.
    var siteURL = "http://" + top.location.host.toString();
    
    var $internalLinks = $("a[href^='"
             + siteURL
             + "'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']");

    public by simonwalker  183  0  4  0

    Magento 2 Canonical URLs Extension By FME

    Magento 2 Canonical URL extension helps you remove duplicate content issues from your eCommerce website with the addition of canonical Meta tags. You can add Magento canonical tags to products, categories, and CMS pages to define its relevancy with other pages. Magento canonical tags extension can configure the addition of canonical meta tags to a
    // Enter here the actual content of the snippet.						

    public by msdn  2240  1  5  0

    AppendPathToUri: Append a relative path to a Uri, handling traling slashes appropiately.

    Append a relative path to a Uri, handling traling slashes appropiately. The base Uri. The relative or absloute URI. The seperator. The appended Uri.
    /// <summary>
    /// Append a relative path to a Uri, handling traling slashes appropiately.
    /// </summary>
    /// <param name="uri">The base Uri.</param>
    /// <param name="relativeOrAbslouteUri">The relative or absloute URI.</param>
    /// <param name="sep">The seperator.</param>
    /// <returns>The appended Uri.</returns>
    internal static Uri AppendPathToUri(Uri uri, string relativeOrAbslouteUri, string sep)
    {
        Uri relativeUri;
    
        // Because of URI's Scheme, URI.TryCreate() can't differentiate a string with colon from an absolute URI. 
        // A workaround is added here to verify if a given string is an absolute URI.
        if (Uri.TryCreate(relativeOrAbslouteUri, UriKind.Absolute, out relativeUri) && (relativeUri.Scheme == "http" || relativeUri.Scheme == "https"))
        {
            // Handle case if relPath is an absolute Uri
            if (uri.IsBaseOf(relativeUri))
            {
                return relativeUri;
            }
            else
            {
                // Happens when using fiddler, DNS aliases, or potentially NATs
                var absoluteUri = new Uri(relativeOrAbslouteUri);
                return new Uri(uri, absoluteUri.AbsolutePath);
            }
        }
    
        var ub = new UriBuilder(uri);
        string appendString = null;
        if (ub.Path.EndsWith(sep))
        {
            appendString = relativeOrAbslouteUri;
        }
        else
        {
            appendString = sep + relativeOrAbslouteUri;
        }
    
        string escapedRelativeOrAbslouteUri = Uri.EscapeUriString(appendString);
        ub.Path += escapedRelativeOrAbslouteUri;
    
        return ub.Uri;
    }

    public by msdn  1519  0  6  0

    GetContainerName: Retrieves the container part of a storage Uri, or "$root" if the container is implicit.

    Retrieves the container part of a storage Uri, or "$root" if the container is implicit. The blob address. If set to true use path style Uris. Name of the container. The trailing slash is always removed. GetContainerName(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder/myblob")) will return "mycontainer" GetConatinerName(new Uri("
    /// <summary>
    /// Retrieves the container part of a storage Uri, or "$root" if the container is implicit.
    /// </summary>
    /// <param name="blobAddress">The blob address.</param>
    /// <param name="usePathStyleUris">If set to <c>true</c> use path style Uris.</param>
    /// <returns>Name of the container.</returns>
    /// <remarks>
    /// The trailing slash is always removed.
    /// <example>
    /// GetContainerName(new Uri("http://test.blob.core.windows.net/mycontainer/myfolder/myblob")) will return "mycontainer"
    /// GetConatinerName(new Uri("http://test.blob.core.windows.net/mycontainer/")) will return "mycontainer"
    /// GetConatinerName(new Uri("http://test.blob.core.windows.net/myblob")) will return "$root"
    /// GetConatinerName(new Uri("http://test.blob.core.windows.net/")) will throw ArgumentException
    /// </example>
    /// </remarks>
    internal static string GetContainerName(Uri blobAddress, bool usePathStyleUris)
    {
        string containerName;
        string blobName;
    
        GetContainerNameAndBlobName(blobAddress, usePathStyleUris, out containerName, out blobName);
    
        return containerName;
    }

    external by IlanFrumer  180145  1  4  0

    ui router - trailing slash

    ui router - trailing slash: ui-router-trailing-slash.coffee
    app.config ($urlRouterProvider)->
    
      ##############################################################################################################################
      # https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-make-a-trailing-slash-optional-for-all-routes
      ##############################################################################################################################
    
      $urlRouterProvider.rule ($injector, $location)->
    
        path = $location.path()
        
        # Note: misnomer. This returns a query object, not a search string
        search = $location.search()
        
        # check to see if the path already ends in '/'
        return if path[path.length - 1] is "/"
        
        # If there was no search string / query params, return with a `/`
        return path + "/"  if Object.keys(search).length is 0
        
        # Otherwise build the search string and return a `/?` prefix
        params = []    
        angular.forEach search, (v, k) ->
          params.push k + "=" + v
    
        path + "/?" + params.join("&")
    
      $urlRouterProvider.otherwise('/')
    
    

    external by Chris Andrew  22  0  1  0

    A helper function for path normalisation that replaces all consecutive slashes with a single forward slash and trims leading and trailing slashes.

    A helper function for path normalisation that replaces all consecutive slashes with a single forward slash and trims leading and trailing slashes.: NormalisePath.php
    PHP
    /**
     * Helper function for consistent path values.
     * 
     * @param string $path
     * @return string
     */
    function NormalisePath($path)
    {
    	return preg_replace('#[\\\|/]+#', '/', trim($path, '\/'));
    }
    
    

    external by Douglas Santos Elias  14  0  1  0

    Slash those slashes with Slasher

    Slash those slashes with Slasher: slasher.rb
    system("cls")
    
    print "Paste the text here: "
    text = gets.chomp!
    
    puts "\n### Menu ###"
    puts "1 - Change '\\' to '/'"     # Change the slash to inverted slash
    puts "2 - Change '/' to '\\'"     # Change the inverted slash to slash
    puts "3 - Change '\\' to '\\\\'"  # Double the slash
    puts "4 - Change '/' to '//'"     # Double the inverted slash
    puts "5 - Change '\\\\' to '\\'"  # Single the slash
    puts "6 - Change '//' to '/'"     # Single the inverted slash
    print "$ "
    option = gets.chomp!
    
    case option.to_i
      when 1
        puts text.gsub!("\\", "/")
      when 2
        puts text.gsub!("/", "\\")
      when 3
        puts text.gsub!("\\", "\\\\\\") # Don't ask me why this works
      when 4
        puts text.gsub!("/", "//")
      when 5
        puts text.gsub!("\\\\", "\\")
      when 6
        puts text.gsub!("//", "/")
      else
        puts "Bye!"
    end
    
    

    external by Igor  102  0  2  0

    Rewrite URL: Replace Double Slashes With Single Slash

    Rewrite URL: Replace Double Slashes With Single Slash: gistfile1.txt
    Rewrite URL: Replace Double Slashes With Single Slash
    
    RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
    RewriteRule . %1/%2 [R=301,L]
    
    
    
    

    external by Pippin Williamson  68  0  1  0

    A Slash command to retrieve earnings in Restrict Content Pro for the specified time period. Based on http://wpninjas.com/using-slack-slash-commands-to-get-edd-sales-info/

    A Slash command to retrieve earnings in Restrict Content Pro for the specified time period. Based on http://wpninjas.com/using-slack-slash-commands-to-get-edd-sales-info/: edd-slack-slash-command.php
    <?php
    
    function pw_rcp_earnings_slash_command() {
    
        # Check to make sure this is a Slash Command Request
        if ( ! isset( $_REQUEST['slack_slash'] ) && 'your_custom_string' != $_REQUEST['slack_slash'] )
            return false;
    
        # Check to see if a token has been passed as well
        if ( ! isset( $_REQUEST['token'] ) )
            return false;
    
        # Set additional text strings if sent
        $text = isset ( $_REQUEST['text'] ) ? $_REQUEST['text'] : '';
    
        # Check that the token is the one that was set in Slack
        if ( 'your_slack_token' == $_REQUEST['token'] ) {
    
            # Gather EDD sales data
            $stats = new RCP_Payments;
            $args  = array();
    
            # check additional text to display appriate data
            switch ( $_REQUEST['text'] ) {
                case 'day':
                    $args['date']['day'] = date( 'd' );
                    $args['date']['month'] = date( 'n' );
                    $args['date']['year'] = date( 'y' );
                    break;
                case 'month':
                    $args['date']['month'] = date( 'n' );
                    $args['date']['year'] = date( 'y' );
                    break;
                case 'year':
                    $args['date']['year'] = date( 'y' );
                    break;
                case 'lifetime':
                    // Default for get_earnings()
                    break;
            }
    
            echo '$' . $stats->get_earnings( $args );
            # We need to die or you will send a bunch of html that Slack won't be able to handle
            die();
        }
    
    }
    add_action( 'init', 'pw_rcp_earnings_slash_command' );
    
    
    
    • Public Snippets
    • Channels Snippets