FEATURE: permalink normalization

Optionally allow admins to apply regex based normalization
to permalinks prior to matching.

This allows us to drop query string, or cleanly ignore slugs, etc.
This commit is contained in:
Sam
2015-07-15 15:32:35 +10:00
parent d20324ece8
commit b772d96f7a
5 changed files with 92 additions and 4 deletions

View File

@@ -2,6 +2,16 @@ require "spec_helper"
describe Permalink do
describe "normalization" do
it "correctly normalizes" do
normalizer = Permalink::Normalizer.new("/(\\/hello.*)\\?.*/\\1|/(\\/bye.*)\\?.*/\\1")
expect(normalizer.normalize("/hello?a=1")).to eq("/hello")
expect(normalizer.normalize("/bye?test=1")).to eq("/bye")
expect(normalizer.normalize("/bla?a=1")).to eq("/bla?a=1")
end
end
describe "new record" do
it "strips blanks" do
permalink = described_class.create(url: " my/old/url ")